I'm using contextmenu
event to capture right clicks. On touch devices that event fired via "long press".
The problem I'm experiencing is that the contextmenu
event doesn't fire on touch devices until touch is released. I could listen for touchstart
/mousedown
events and set timeout, but it won't be accurate since each device might have its own delay for long press
activation.
So, is there a way accurately detect when long press
is activated on touch screen devices? (On some devices there is haptic feedback when long press
was activated)
As discussed in the comment section.
On most devices
contextmenu
fires without releasing the touch, so in most cases it should be fine to use thecontextmenu
event to get the desired result.
This might be a bug in the DevTools of Chromium, since you tested with that. I recommend to simply use the contextmenu
event.
In case the specific device really fires the context menu on touch release, the user expects the same behavior on your website/app, so it should be fine to go this route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With