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 is triggered. |
clientY | Returns the vertical coordinate of the mouse pointer relative to the current window when the mouse event is triggered. |
ctrlKey | Returns whether the "CTRL" key was pressed when the keyboard event was triggered. |
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 associated with 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 on an element. |
onmouseenter | When the pointer moves over an element, this event occurs. |
onmouseleave | Questo evento si verifica quando il puntatore si allontana dall'elemento. |
onmousemove | Questo evento si verifica quando il puntatore si muove sopra l'elemento. |
onmouseout | Questo evento si verifica quando l'utente sposta il puntatore del mouse fuori dall'elemento o dai suoi elementi figli. |
onmouseover | Questo evento si verifica quando il puntatore si muove sull'elemento o sui suoi elementi figli. |
onmouseup | Questo evento si verifica quando l'utente rilascia il pulsante del mouse sull'elemento. |