MouseEvent buttons Property
Example
Find out which mouse button(s) that was pressed when a mouse event was triggered:
var x = event.buttons;
Try it yourself »
Definition and Usage
The buttons property returns a number that indicates which mouse button or mouse buttons were pressed when a mouse event was triggered.
This property is mostly used together with the onmousedown event.
Tip: Due to lack of browser support, you may want to look at the button property instead.
Note: This property is read-only.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
buttons | Not supported | 9.0 | Yes | Not supported | Not supported |
Syntax
event.buttons
Technical Details
Return Value: |
A Number, representing
one or more mouse buttons that were pressed when the mouse event occured. If more
than one button is pressed, the values are combined to produce a new number
(For example, if the left button (1) and the right button (2) are pressed,
the returned value is 1+2, which is 3). Possible values:
|
---|---|
DOM Version: | DOM Level 3 Events |
Related Pages
HTML DOM reference: MouseEvent button Property
HTML DOM reference: MouseEvent which Property
Event Object