Introduction

About long press hook

React hook for detecting click / tap / point and hold event

Main features

  • Mouse, Touch and Pointer events support

  • Pass custom context and access it in callback

  • Cancel long press if moved too far from the target

  • Flexible callbacks: onStart, onMove, onFinish, onCancel

  • Disable hook when necessary

  • Filter undesired events (like mouse right clicks)

What it does

  • Handle long press on single React component

  • Handle long press on multiple React components (e.g. list of elements where you can provide element id as hook context to distinguish which element triggered long press). For more info see context.

  • Handle custom long press (you can manually attach different handlers to different React components). For more info see handlers.

What it does not

  • It does not prevent browser specific behaviour on long press. Most of them can be handled using CSS.

Last updated