The onmousedown attribute is an inline event handler for the mousedown event. It runs when a pointing-device button is pressed while the pointer is inside the element — before a full click completes.
Compare with onmouseup (release) and click (press + release on the same element). MDN also notes that pointerdown behaves differently for multi-button mice.
Baseline · Widely available.
Not deprecated and not experimental. Stable across modern browsers since about July 2015.
Accessibility.
Do not make important actions mouse-only. Provide keyboard (and, when needed, touch/pointer) alternatives so everyone can use the control.
Syntax
HTML Syntax
syntax.html
<element onmousedown="script">
script is JavaScript that runs on press. Pass event to read event.button, event.clientX, and event.clientY. Script alternative: element.addEventListener("mousedown", handler).
Press and drag away before release — you may get mousedown without click.
Prefer addEventListener in apps so multiple handlers can coexist.
Edge Cases & Pitfalls
Most surprises come from treating every press as a completed click, or ignoring keyboard users.
timing
Press is not a click
Users can press, drag off, and release elsewhere — click may never fire. Choose the event that matches your intent.
a11y
Keyboard users skip mousedown
Activating a button with Enter/Space does not fire mousedown the same way. Use real <button> / links and also handle click or keyboard events.
buttons
Every mouse button can fire mousedown
MDN: physical mice fire mousedown for each button. pointerdown only fires for the first button press until all are released.
context
Right-click still fires mousedown
Secondary-button press triggers mousedown and may open the context menu (oncontextmenu).
touch
Touch may synthesize mouse events
Do not assume perfect parity on phones. For multi-device UIs, consider Pointer Events or dedicated touch handling.
Compatibility
Browser Support
onmousedown is an HTML event handler for the mousedown event in the browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
onmousedown
Widely available since about July 2015. Supported across modern desktop and mobile browsers (with the usual mouse-vs-touch caveats).
98%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetModern
Full support
Internet ExplorerLegacy support
Supported
onmousedownWidely supported
Bottom line: Safe to use for press detection. Prefer click for primary actions; use addEventListener in larger apps.
Remember
Key Takeaways
Role: run script the moment a pointer button is pressed.
vs click:mousedown is press; click is press + release on the same element.
API: use event.button and coordinates from the MouseEvent.
A11y: never make critical features mouse-only.
One line: use onmousedown for the press moment — use onclick for completed activation.
Frequently Asked Questions
It is an inline event handler that runs JavaScript when the mousedown event fires — a pointing-device button is pressed while the pointer is inside the element.
mousedown fires as soon as the button is pressed. click fires after a full press and release while the pointer stays on the same element. Use click for most button actions; use mousedown when you need the press moment (for example press-and-hold UI).
onmousedown runs on press. onmouseup runs when the button is released. Release can happen on a different element than the press.
On a MouseEvent, button is 0 for the primary (usually left) button, 1 for the auxiliary (usually middle/wheel) button, and 2 for the secondary (usually right) button.
Many browsers synthesize mouse events for taps, but behavior varies. Prefer Pointer Events or also handle touch for reliable multi-device input.
No. The mousedown event is Baseline widely available. Inline handlers are fine for learning; apps often use addEventListener("mousedown", handler).