JavaScript How to check if the middle mouse button has been pressed?

Опубликовано: 14 Октябрь 2024
на канале: Samovar tutorials
1,354
11

How to check if the middle mouse button has been pressed?
There’s some site.
Let’s add an eventListener to the document object.
The name of the event is mousedown.
The event object has button property.
If this property equals one that means middle mouse button.
To check if the middle mouse button is up we need the mouseup event.
And check if the button property of the event object equals one.
Let’s check it out.
Middle mouse button is down.
And up.

It works!