minwork / use-long-press

React hook for detecting click (or tap) and hold event
MIT License
120 stars 12 forks source link

Right-click behaves like long-press #27

Closed etabackman closed 2 years ago

etabackman commented 2 years ago

When right-clicking momentarily (not long click), the useLongPress callback function is triggered.

How can I prevent this?

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

elderapo commented 2 years ago

This is still the case so plz don't close it :)

minwork commented 2 years ago

Hey, I will look into it. Looks like it needs to be handled internally within the library.

minwork commented 2 years ago

You can now overcome this issue by setting proper events filtering using new option filterEvents like this:

// ...
// If mouse event, pass only "main mouse button" clicks
filterEvents: (event) => 'button' in event ? event.button === 0 : true
// ...

See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button