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.

button

Summary

Gets the mouse button that caused an event.

Property of dom/MouseEventdom/MouseEvent

Syntax

Note: This property is read-only.

var button = event.button;

Return Value

Returns an object of type NumberNumber

One of the following values -

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

Any value higher than 2 represents other less common buttons.

Related specifications

DOM Level 3 Events
Working Draft

Attributions