MouseEvent button Property
Definition and Usage
The button property returns a number indicating which mouse button was pressed when the mouse event was triggered.
This property is mainly used with the onmousedown event.
Note:This property is read-only.
Example
Find out which mouse button was pressed when the mouse event was triggered:
alert("You pressed button: " + event.button)
Syntax
event.button
Technical Details
Return value: |
Numeric values representing the mouse button pressed when the mouse event occurs. Possible values:
Note:Internet Explorer 8 and earlier versions have different return values:
Note:For mice configured for left-handed use, the return value is reversed. |
---|---|
DOM Version: | DOM Level 2 Events |
Browser Support
The numbers in the table indicate the first browser version that fully supports the property.
Properties | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
button | Support | Support | Support | Support | 8.0 |
Related Pages
HTML DOM Reference Manual:MouseEvent buttons Property
HTML DOM Reference Manual:MouseEvent which Property