Function getEvent

  • Gets the appropriate event name based on device capabilities and event type. Automatically detects whether to use touch, pointer, or mouse events based on device support.

    Parameters

    • type:
          | "end"
          | "start"
          | "move"
          | "click"

      The type of event to get ('start', 'move', 'end', or 'click')

    Returns string

    The appropriate event name string for the current device

    Error if called in a non-browser environment

    const startEvent = getEvent('start'); // Returns 'touchstart', 'pointerdown', or 'mousedown'
    element.addEventListener(startEvent, handler);