0
Can i double click addEventListener ??
I want to click "click" and "contextmenu" at the same time Is it possible?
4 Respostas
+ 3
How could it be? click detects left mouse button, contextmenu detects right mouse button.
And why you want this?
+ 3
I don't know if that's possible. As I understand it, addEventListener() accepts one event name and a function assigned as the event handler.
+ 1
Interesting idea.
vanilla JavaScript does not detect two mouse event at the same time.
The MouseEvent.button property tells you which button is pressed to trigger the event.
https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
To achieve what you wanted to do, You need to use two global variables, one for remembering whether Left Mouse button is clicked, the other one for remembering whether Right Mouse button is clicked.
You can then define a callback function which check if both flags are true.
If not, set a timer to change the flag back to its initial state.
You can then assign this same callback to listen to both events.
That should help you achieve what you want.
0
Ipang eventlistener's condition
I want "click"&&"contextmenu"