The MouseEvent.buttons read-only property indicates which buttons are pressed on the mouse (or other input device) when the event is triggered.

Each button that can be pressed is represented by a given number (see below). If more than one button is pressed, the value of the buttons is combined to produce a new number. For example, if the secondary (2) and auxilary (4) buttons are pressed together, the value is 6 (i.e. 2 + 4).

Note: Do not confuse this property with the MouseEvent.button property. The MouseEvent.buttons property indicates the state of buttons pressed during any kind of mouse event, while the MouseEvent.button property only guarantees the correct value for mouse events caused by pressing or releasing one or multiple buttons.


var buttonPressed = instanceOfMouseEvent.buttons

Return value

A number representing one or more buttons. For more than one button pressed simultaneously, the values are combined (e.g. 3 is primary + secondary).

  • : No button or un-initialized
  • : Primary button (usually left)
  • : Secondary button (usually right)
  • : Auxilary button (usually middle or mouse wheel button)
  • : 4th button (typically the "Browser Back" button)
  • 16 : 5th button (typically the "Browser Forward" button)


Specification Status Comment
Document Object Model (DOM) Level 3 Events Specification
The definition of 'MouseEvent.buttons' in that specification.
Obsolete Initial definition

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 43Edge Full support YesFirefox Full support Yes
Full support Yes
Notes Resrictions apply depending on OS.
IE Full support 9Opera Full support YesSafari No support NoWebView Android No support NoChrome Android No support NoEdge Mobile Full support YesFirefox Android ? Opera Android ? Safari iOS No support NoSamsung Internet Android ?


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

Firefox notes

Firefox supports the buttons attribute on Windows, Linux (GTK), and Mac OS with the following restrictions:

  • Utilities allow customization of button actions so that primary may not the the left button on the device, secondary may not be the right button, and so on. The middle (wheel) button, 4th button and 5th button might not be assigned a value, even when they are pressed.
  • Single button devices may emulate additional buttons with combinations of button and keyboard presses
  • Touch devices may emulate buttons with configurable gestures (e.g. single touch for primary, two-finger touch for secondary, etc.)
  • On Linux (GTK), the 4th button and the 5th button are not supported. In addition, a mouseup event always has the releasing button information in this attribute value.
  • On Mac OS X 10.5, the buttons attribute always returns 0 because there is no platform API for implementing this feature.

See also

Document Tags and Contributors

Last updated by: fscholz,