werkbank
    Preparing search index...

    Function useLongPress

    • Hook to handle long press interactions.

      Type Parameters

      • E extends Element

        The element type.

      Parameters

      • onLongPress: OnLongPress<E>

        The function to call when a long press is detected.

      • config: Config = {}

        Configuration options (delay, preventDefault).

      Returns { onPointerDown: PointerEventHandler; onPointerUp: PointerEventHandler }

      Event handlers for onPointerDown and onPointerUp.

      Triggers the callback after a specified delay while the pointer is held down. Can optionally prevent the default behavior of the pointerup event.

      const { onPointerDown, onPointerUp } = useLongPress(() => {
      console.log("Long pressed!");
      });
      return <button onPointerDown={onPointerDown} onPointerUp={onPointerUp}>Press Me</button>;