{{APIRef("DOM Events")}}{{Non-standard_header}}
The MouseEvent.which
read-only property indicates which button was pressed on the mouse to trigger the event. The standard alternatives to this property are {{ domxref("MouseEvent.button") }} and {{ domxref("MouseEvent.buttons") }}.
Syntax
var buttonPressed = instanceOfMouseEvent.which
Return value
A number representing a given button:
0
: No button1
: Left button2
: Middle button (if present)3
: Right button
For a mouse configured for left-handed use, the button actions are reversed. In this case, the values are read from right to left.
Specification
{{DOM0}}
Browser compatibility
{{CompatibilityTable}}
Feature | Firefox (Gecko) | Chrome | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatGeckoDesktop(1)}}[1] | 1.0 | 9.0 | 5.0 | 1.0 |
Feature | Firefox Mobile (Gecko) | Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{ CompatGeckoMobile(1) }} [1] | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
[1] On {{event("mousemove")}} events, the which
property is incorrectly always set to 1
{{bug(1048294)}}.
See also
- {{ domxref("MouseEvent") }}