Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 722177 of MouseEvent.which

  • Revision slug: Web/API/MouseEvent.which
  • Revision title: MouseEvent.which
  • Revision id: 722177
  • Created:
  • Creator: Marijn
  • Is current revision? No
  • Comment Note uselessness on mousemove events

Revision Content

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") }}

Revision Source

<h2 id="Summary" style="line-height: 30px;">Summary</h2>

<p>The&nbsp;<code>which</code>&nbsp;property indicates which button was pressed on the mouse to trigger the event.</p>

<h2 id="Syntax" style="line-height: 30px;">Syntax</h2>

<pre class="syntaxbox" style="font-size: 14px;">
var buttonPressed = <em>instanceOfMouseEvent</em>.which
</pre>

<h2 id="Value" style="line-height: 30px;">Value</h2>

<p>A number representing a given button:</p>

<ul>
 <li><code>0</code>&nbsp;:&nbsp;No button</li>
 <li><font face="Courier New, Andale Mono, monospace">1</font>&nbsp;: Left button</li>
 <li><font face="Courier New, Andale Mono, monospace">2</font> : Middle button (if present)</li>
 <li><font face="Courier New, Andale Mono, monospace">3</font> : Right button</li>
</ul>

<p>For a mouse configured for left-handed use, the button actions are reversed. In this case, the values are read from right to left.</p>

<p><strong>Note:&nbsp;</strong>Only Webkit-based browsers attach a useful <code>which</code> property to&nbsp;<code>mousemove</code>&nbsp;events.</p>

<h2 id="Specifications" style="line-height: 30px;">Specifications</h2>

<p>None.</p>

<h2 id="Browser_compatibility" name="Browser_compatibility" style="line-height: 30px;">Browser compatibility</h2>

<p>{{page("/en-US/docs/Web/API/MouseEvent","Browser compatibility")}}</p>

<h2 id="See_also" name="See_also" style="line-height: 30px;">See also</h2>

<ul>
 <li>{{ domxref("MouseEvent") }}</li>
</ul>
Revert to this revision