HTML DOM MouseEvent

❮ DOM Events ❮ Event Objects


The MouseEvent Object

The MouseEvent Object handles events that occur when the mouse interacts with the HTML document.

Mouse Events

Event Occurs When
onclick A user clicks on an element
oncontextmenu A user right-clicks on an element
ondblclick A user double-clicks on an element
onmousedown A mouse button is pressed over an element
onmouseenter The mouse pointer moves into an element
onmouseleave The mouse pointer moves out of an element
onmousemove The mouse pointer moves over an element
onmouseout The mouse pointer moves out of an element
onmouseover The mouse pointer moves onto an element
onmouseup A mouse button is released over an element

MouseEvent Properties

Property Returns
altKey If the ALT key is pressed
button Which mouse button is pressed
buttons Which mouse buttons were pressed
clientX The X coordinate of the mouse pointer (window relative)
clientY The Y coordinate of the mouse pointer (window relative)
ctrlKey If the CTRL key is pressed
detail The details about an event
metaKey If the META key is pressed
offsetX The X coordinate of the mouse pointer (target relative)
offsetY The Y coordinate of the mouse pointer (target relative)
pageX The X coordinate of the mouse pointer (document relative)
pageY The Y coordinate of the mouse pointer (document relative)
relatedTarget The element that triggered the mouse event
screenX The X coordinate of the mouse pointer (screen relative)
screenY The Y coordinate of the mouse pointer (screen relative)
shiftKey If the SHIFT key is pressed
which Deprecated (Avoid using it)
Use the button property instead

Inherited Properties and Methods

The MouseEvent inherits all the properties and methods from:

The UiEvent

The Event Object


❮ DOM Events ❮ Event Objects

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.