Summary
The which
property indicates which button was pressed on the mouse to trigger the event.
Syntax
var buttonPressed = instanceOfMouseEvent.which
Value
A number representing a given button:
0
: No button- 1 : Left button
- 2 : 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.
Note: Only Webkit-based browsers attach a useful which
property to mousemove
events.
Specifications
None.
Browser compatibility
{{page("/en-US/docs/Web/API/MouseEvent","Browser compatibility")}}
See also
- {{ domxref("MouseEvent") }}