MouseEvent buttons property
Definition and usage
button property returns a number indicating which or which mouse buttons were pressed when the mouse event was triggered.
This property is mainly used with the onmousedown event.
Tip:Due to lack of browser support, you may need to refer to button property.
Note:This property is read-only.
Example
Find out which mouse button was pressed when the mouse event was triggered:
var x = event.buttons;
Syntax
event.buttons
Technical details
Return value: |
Numeric value, representing one or more mouse buttons pressed during a mouse event. If multiple buttons are pressed, these values are combined to produce a new number (for example, if the left button (1) and the right button (2) are pressed, the return value is 1+2, which is 3). Possible values:
Note:For left-handed mouse configuration, the return value is reversed. |
---|---|
DOM Version: | DOM Level 3 Events |
浏览器支持
表中的数字注明了完全支持该属性的首个浏览器版本。
Makamilo | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
buttons | 53.0 | 9.0 | Inahatiliwa | Hinasimamishwa | Inahatiliwa |
Vipindi vya habari
Makao ya HTML DOM:Kipimo cha button kwa MouseEvent
Makao ya HTML DOM:Kipimo cha which kwa MouseEvent