Indicates which mouse button caused the event.
var buttonCode = event.button;
Returns an integer value indicating the button that changed state.
- 0 for standard 'click', usually left button
- 1 for middle button, usually wheel-click
- 2 for right button, usually right-click
The order of buttons may be different depending on how the pointing device has been configured.
Because mouse clicks are frequently intercepted by the user interface, it may be difficult to detect buttons other than those for a standard mouse click (usually the left button) in some circumstances.
Users may change the configuration of buttons on their pointing device so that if an event's button property is zero, it may not have been caused by the button that is physically left–most on the pointing device; however, it should behave as if the left button was clicked in the standard button layout.
DOM 2 Events Specification: button