HTML DOM MouseEvent
MouseEvent object
Events that occur when interacting with the HTML document through the mouse belong to the MouseEvent object.
Mouse event properties and methods
Property/Method | Description |
---|---|
altKey | Returns whether the 'ALT' key was pressed when the mouse event was triggered. |
button | Returns the mouse button pressed when the mouse event is triggered. |
buttons | Returns the mouse button pressed when the mouse event is triggered. |
clientX | Returns the horizontal coordinate of the mouse pointer relative to the current window when the mouse event was triggered. |
clientY | Returns the vertical coordinate of the mouse pointer relative to the current window when the mouse event was triggered. |
ctrlKey | Returns whether the 'CTRL' key was pressed when the key mouse event occurred. |
getModifierState() | Returns true if the specified key is activated. |
metaKey | Returns whether the 'META' key was pressed when the event was triggered. |
movementX | Returns the horizontal coordinate of the mouse pointer relative to the position of the previous mousemove event. |
movementY | Returns the vertical coordinate of the mouse pointer relative to the position of the previous mousemove event. |
offsetX | Returns the horizontal coordinate of the mouse pointer relative to the edge of the target element. |
offsetY | Returns the vertical coordinate of the mouse pointer relative to the edge of the target element. |
pageX | Returns the horizontal coordinate of the mouse pointer relative to the document when the mouse event is triggered. |
pageY | Returns the vertical coordinate of the mouse pointer relative to the document when the mouse event is triggered. |
region | |
relatedTarget | Returns the element related to the element that triggered the mouse event. |
screenX | Returns the horizontal coordinate of the mouse pointer relative to the screen when the event was triggered. |
screenY | Returns the vertical coordinate of the mouse pointer relative to the screen when the event was triggered. |
shiftKey | Returns whether the 'SHIFT' key was pressed when the event was triggered. |
which | Returns the mouse button pressed when the mouse event is triggered. |
Inherited properties and methods
The MouseEvent inherits all properties and methods from the following objects:
Event type
These event types belong to the MouseEvent object:
Event | Description |
---|---|
onclick | This event occurs when the user clicks an element. |
oncontextmenu | This event occurs when the user right-clicks an element to open the context menu. |
ondblclick | This event occurs when the user double-clicks an element. |
onmousedown | This event occurs when the user presses the mouse button over an element. |
onmouseenter | This event occurs when the pointer moves over an element. |
onmouseleave | This event occurs when the pointer is moved out of an element. |
onmousemove | This event occurs when the pointer is moved over an element. |
onmouseout | This event occurs when the user moves the mouse pointer out of an element or any of its child elements. |
onmouseover | This event occurs when the pointer moves over an element or any of its child elements. |
onmouseup | This event occurs when the mouse button is released over an element. |