Element: mousedown event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The mousedown event is fired at an Element when a pointing device button is pressed while the pointer is inside the element.

This differs from the click event in that click is fired after a full click action occurs; that is, the mouse button is pressed and released while the pointer remains inside the same element. mousedown is fired the moment the button is initially pressed.

This behavior is different from pointerdown events. When using a physical mouse, mousedown events fire whenever any button on a mouse is pressed down. pointerdown events fire only upon the first button press; subsequent button presses don't fire pointerdown events.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("mousedown", (event) => { })

onmousedown = (event) => { }

Event type

A MouseEvent. Inherits from UIEvent and Event.

Event UIEvent MouseEvent

Examples

See mousemove event for example code.

Specifications

Specification
Pointer Events
# mousedown
HTML
# handler-onmousedown

Browser compatibility

See also