The buttons property of mouse event is used to return a number. The number indicates which mouse button or mouse buttons were pressed when a mouse event was triggered.
This property is usually used along with the onmousedown event. This property is read-only.
Due to lack of browser support, you may want to look at the button property instead.
It returns a number which represents one or more mouse buttons that were pressed. If more than one button is pressed, like the left button (1) and the right button (2) then it returns 3(1+2).
- 1: Left mouse button
- 2: Right mouse button
- 4: Wheel button or middle button
- 8: Fourth mouse button or the “Browser Back” button
- 16: Fifth mouse button or the “Browser Forward” button
Supported Browsers: The browsers supported by MouseEvent buttons Property are listed below:
- Google Chrome 53.0
- Internet Explorer 9.0