This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

buttons

Summary

Gets a value that indicates which mouse buttons a user pressed.

Property of dom/MouseEventdom/MouseEvent

Syntax

Note: This property is read-only.

var pressedButtons = event.buttons;

Return Value

Returns an object of type unsigned shortunsigned short

A bitmask that represents the pressed mouse buttons.

  • 0 - No button.
  • 1 - The primary button (usually the left mouse button).
  • 2 - The auxiliary button (usually the middle/wheel mouse button).
  • 4 - The secondary button (usually the right mouse button).

Other values are always expressed as a power of 2, like 8, 16, 32 and so on and represent other buttons.

Related specifications

DOM Level 3 Events
Working Draft

Attributions