MouseEvent buttons Property in JavaScript
MouseEvent buttons Property in JavaScript
The buttons property is a read-only property and it is used to return a number that indicates which mouse button or mouse buttons were pressed when a mouse event was triggered. It is used in combination with onmousedown event. Its possible values are:-
- 1 => Left mouse button
- 2 => Right mouse button
- 4 => Wheel/middle button
- 8 => Fourth mouse button i.e, Browser Back button
- 16 => Fifth mouse button i.e, Browser Forward button
Syntax:-
Its syntax is:- event.buttons
Return:-
Its return is:- number denoting which mouse buttons are pressed when mouse event occured