I used event.type == 'click' (left) vs. event.type == 'contextmenu' (right).
Pointer Events method of checking left- or right-click
-
08-10-2022 - |
سؤال
I've configured Pointer Events through pointerevents-polyfill.
There's an issue I have where I cannot differentiate between left- and right-clicks where right-clicking a nav item will do the same action as left-clicking instead of opening the right-click menu.
The specific event I'm using is pointerup.
Is there a way with Pointer Events to check if the event is a left- or right-click?
المحلول 2
نصائح أخرى
Looks like there is a property called button that has a value of 0 if it's the primary pointer (left mouse button).
I haven't used this library but from looking at the source and the W3C spec it would appear that way.
You can always print/debug the event and see what the property is.
لا تنتمي إلى StackOverflow