The MouseEvent
THE WORLD'S LARGEST WEB DEVELOPER SITE

HTML DOM MouseEvent

❮ DOM Events ❮ Event Objects


The MouseEvent Object

Events that occur when the mouse interacts with the HTML document belongs to the MouseEvent Object.


MouseEvent Properties and Methods

Property/Method Description
altKey Returns whether the "ALT" key was pressed when the mouse event was triggered
button Returns which mouse button was pressed when the mouse event was triggered
buttons Returns which mouse buttons were pressed when the mouse event was 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 mouse event was triggered
getModifierState()  
metaKey Returns whether the "META" key was pressed when an event was triggered
movementX Returns the horizontal coordinate of the mouse pointer relative to the position of the last mousemove event
movementY Returns the vertical coordinate of the mouse pointer relative to the position of the last mousemove event
offsetX Returns the horizontal coordinate of the mouse pointer relative to the position of the edge of the target element
offsetY Returns the vertical coordinate of the mouse pointer relative to the position of the edge of the target element
pageX Returns the horizontal coordinate of the mouse pointer, relative to the document, when the mouse event was triggered
pageY Returns the vertical coordinate of the mouse pointer, relative to the document, when the mouse event was 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 an event was triggered
screenY Returns the vertical coordinate of the mouse pointer, relative to the screen, when an event was triggered
shiftKey Returns whether the "SHIFT" key was pressed when an event was triggered
which Returns which mouse button was pressed when the mouse event was triggered

Inherited Properties and Methods

The MouseEvent inherits all the properties and methods from:

The UiEvent

The Event Object


Event Types

These event types belongs to the MouseEvent Object:

Event Description
onclick The event occurs when the user clicks on an element
oncontextmenu The event occurs when the user right-clicks on an element to open a context menu
ondblclick The event occurs when the user double-clicks on an element
onmousedown The event occurs when the user presses a mouse button over an element
onmouseenter The event occurs when the pointer is moved onto an element
onmouseleave The event occurs when the pointer is moved out of an element
onmousemove The event occurs when the pointer is moving while it is over an element
onmouseout The event occurs when a user moves the mouse pointer out of an element, or out of one of its children
onmouseover The event occurs when the pointer is moved onto an element, or onto one of its children
onmouseup The event occurs when a user releases a mouse button over an element

❮ DOM Events ❮ Event Objects