docs.rodeo

MDN Web Docs mirror

Element: mousedown event

{{APIRef}} 

The mousedown event is fired at an {{domxref("Element")}}  when a pointing device button is pressed while the pointer is inside the element.

This differs from the {{domxref("Element/click_event", "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 {{domxref("Element/pointerdown_event", "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 {{domxref("EventTarget.addEventListener", "addEventListener()")}} , or set an event handler property.

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

onmousedown = (event) => {};

Event type

A {{domxref("MouseEvent")}} . Inherits from {{domxref("UIEvent")}}  and {{domxref("Event")}} .

{{InheritanceDiagram("MouseEvent")}} 

Event properties

This interface also inherits properties of its parents, {{domxref("UIEvent")}}  and {{domxref("Event")}} .

Examples

See mousemove event for example code.

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN