mozilla

Revision 13787 of MouseEvent

  • Revision slug: DOM/MouseEvent
  • Revision title: MouseEvent
  • Revision id: 13787
  • Created:
  • Creator: andrewla
  • Is current revision? No
  • Comment one or more formatting changes

Revision Content

The DOM MouseEvent represents events that occur due to the user interacting with a pointing device (such as a mouse). It's represented by the {{ interface("nsINSDOMMouseEvent") }} interface, which extends the {{ interface("nsIDOMMouseEvent") }} interface.

Method overview

boolean getModifierState(in DOMString keyArg);

Properties

Property Type Description
screenX long
The X coordinate of the mouse pointer in global (screen) coordinates. Read only.
screenY
long
The Y coordinate of the mouse pointer in global (screen) coordinates. Read only.
clientX
long
The X coordinate of the mouse pointer in local (DOM content) coordinates. Read only.
clientY
long
The Y coordinate of the mouse pointer in local (DOM content) coordinates. Read only.
ctrlKey
boolean
true if the control key was down when the mouse event was fired. Read only.
shiftKey
boolean
true if the shift key was down when the mouse event was fired. Read only.
altKey
boolean
true if the alt key was down when the mouse event was fired. Read only.
metaKey
boolean
true if the meta key was down when the mouse event was fired. Read only.
button
unsigned short
The button number that was pressed when the mouse event was fired: Left button=0, middle button=1 (if present), right button=2. For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left. Read only.
buttons {{ dom_level("3") }} {{ gecko_minversion_inline("15.0") }} unsigned short

The buttons being pressed when the mouse event was fired: Left button=1, Right button=2, Middle (wheel) button=4, 4th button (typically, "Browser Back" button)=8, 5th button (typically, "Browser Forward" button)=16. If two or more buttons are pressed, returns the logical sum of the values. E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). Read only.

Gecko supports this attribute on Windows, Linux (GTK) and Mac.
On Windows, if user installed a mouse driver and its utility software which can customize button actions (e.g., IntelliPoint and SetPoint), the Middle (wheel) button, 4th button and 5th button may not be set actually even when they're pressed.
On Linux (GTK), 4th button and 5th button are not supported. And also, mouseup event always have the releasing button information in this attribute value.
On Mac OS X 10.5, buttons attribute always returns 0 because there is no platform API for implementing this feature.
relatedTarget
{{ interface("nsIDOMEventTarget") }} The target to which the event applies. Read only.
mozPressure {{ gecko_minversion_inline("2.0") }} {{ non-standard_inline() }} float The amount of pressure applied to a touch or tablet device when generating the event; this value ranges between 0.0 (minimum pressure) and 1.0 (maximum pressure). Read only.

Methods

getModifierState()

Returns the current state of the specified modifier key. See the document of KeyboardEvent.getModifierState() for the detail. {{ dom_level("3") }} {{ gecko_minversion_inline("15.0") }}

boolean getModifierState(
  in DOMString keyArg
);

Specification

See also

Revision Source

<p>The DOM <code>MouseEvent</code> represents events that occur due to the user interacting with a pointing device (such as a mouse). It's represented by the {{ interface("nsINSDOMMouseEvent") }} interface, which extends the {{ interface("nsIDOMMouseEvent") }} interface.</p>
<h2 id="Method_overview">Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>boolean <a href="/en/DOM/KeyboardEvent#getModifierState()" title="en/DOM/KeyboardEvent#getModifierState()">getModifierState</a>(in DOMString keyArg);<br> </code></td> </tr> </tbody>
</table>
<h2 id="Properties">Properties</h2>
<table class="standard-table"> <tbody> <tr> <td class="header">Property</td> <td class="header">Type</td> <td class="header">Description</td> </tr> <tr> <td><code>screenX</code></td> <td><code>long<br> </code></td> <td>The X coordinate of the mouse pointer in global (screen) coordinates. <strong>Read only.</strong></td> </tr> <tr> <td><code>screenY<br> </code></td> <td><code>long<br> </code></td> <td>The Y coordinate of the mouse pointer in global (screen) coordinates. <strong>Read only.</strong></td> </tr> <tr> <td><code>clientX<br> </code></td> <td><code>long<br> </code></td> <td>The X coordinate of the mouse pointer in local (DOM content) coordinates. <strong>Read only.</strong></td> </tr> <tr> <td><code>clientY<br> </code></td> <td><code>long<br> </code></td> <td>The Y coordinate of the mouse pointer in local (DOM content) coordinates. <strong>Read only.</strong></td> </tr> <tr> <td><code>ctrlKey<br> </code></td> <td><code>boolean<br> </code></td> <td><code>true</code> if the control key was down when the mouse event was fired. <strong>Read only.</strong></td> </tr> <tr> <td><code>shiftKey<br> </code></td> <td><code>boolean<br> </code></td> <td><code>true</code> if the shift key was down when the mouse event was fired. <strong>Read only.</strong></td> </tr> <tr> <td><code>altKey<br> </code></td> <td><code>boolean<br> </code></td> <td><code>true</code> if the alt key was down when the mouse event was fired. <strong>Read only.</strong></td> </tr> <tr> <td><code>metaKey<br> </code></td> <td><code>boolean<br> </code></td> <td><code>true</code> if the meta key was down when the mouse event was fired. <strong>Read only.</strong></td> </tr> <tr> <td><code>button<br> </code></td> <td><code>unsigned short<br> </code></td> <td>The button number that was pressed when the mouse event was fired: Left button=0, middle button=1 (if present), right button=2. For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left. <strong>Read only.</strong></td> </tr> <tr> <td><code>buttons</code> {{ dom_level("3") }} {{ gecko_minversion_inline("15.0") }}</td> <td><code>unsigned short</code></td> <td> <p>The buttons being pressed when the mouse event was fired: Left button=1, Right button=2, Middle (wheel) button=4, 4th button (typically, "Browser Back" button)=8, 5th button (typically, "Browser Forward" button)=16. If two or more buttons are pressed, returns the logical sum of the values. E.g., if Left button and Right button are pressed, returns 3 (=1 | 2). <strong>Read only.</strong></p> <div class="note">Gecko supports this attribute on Windows, Linux (GTK) and Mac.</div> <div class="note">On Windows, if user installed a mouse driver and its utility software which can customize button actions (e.g., IntelliPoint and SetPoint), the Middle (wheel) button, 4th button and 5th button may not be set actually even when they're pressed.</div> <div class="note">On Linux (GTK), 4th button and 5th button are not supported. And also, <code>mouseup</code> event always have the releasing button information in this attribute value.</div> <div class="note">On Mac OS X 10.5, buttons attribute always returns 0 because there is no platform API for implementing this feature.</div> </td> </tr> <tr> <td><code>relatedTarget<br> </code></td> <td>{{ interface("nsIDOMEventTarget") }}</td> <td>The target to which the event applies. <strong>Read only.</strong></td> </tr> <tr> <td><code>mozPressure</code> {{ gecko_minversion_inline("2.0") }} {{ non-standard_inline() }}</td> <td><code>float</code></td> <td>The amount of pressure applied to a touch or tablet device when generating the event; this value ranges between 0.0 (minimum pressure) and 1.0 (maximum pressure). <strong>Read only.</strong></td> </tr> </tbody>
</table>
<h2 id="Methods">Methods</h2>
<h3 id="getModifierState()">getModifierState()</h3>
<p>Returns the current state of the specified modifier key. See the document of <a href="/en/DOM/KeyboardEvent#getModifierState()" title="en/DOM/KeyboardEvent#getModifierState()"><code>KeyboardEvent.getModifierState()</code></a> for the detail. {{ dom_level("3") }} {{ gecko_minversion_inline("15.0") }}</p>
<pre>boolean getModifierState(
  in DOMString keyArg
);
</pre>
<h2 id="Specification">Specification</h2>
<ul> <li><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MouseEvent" title="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MouseEvent">DOM Level 2: MouseEvent</a></li> <li> <p><a class="external" href="http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent" title="http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent">DOM 3 Events: MouseEvent</a></p> </li>
</ul>
<h2 id="See_also">See also</h2>
<ul> <li><a href="/en/DOM/UIEvent" title="UIEvent">UIEvent</a></li> <li><a href="/en/DOM/event" title="Event">Event</a></li>
</ul>
Revert to this revision