You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!

The onmousedown property of the GlobalEventHandlers mixin is an EventHandler that processes mousedown events.

The mousedown event fires when the user depresses the mouse button.

Note: The opposite of onmousedown is onmouseup.


target.onmousedown = functionRef;


functionRef is a function name or a function expression. The function receives a MouseEvent object as its sole argument.


This example reveals part of an image when you press and hold a mouse button. It uses the onmousedown, onmouseup, and onmousemove event handlers.


<div class="container">
  <div class="view" hidden></div>
  <img src="">


.container {
  width: 320px;
  height: 213px;
  background: black;

.view {
  position: absolute;
  width: 100px;
  height: 100px;
  background: white;
  border-radius: 50%;

img {
  mix-blend-mode: darken;


function showView(event) {
  view.removeAttribute('hidden'); = event.clientX - 50 + 'px'; = event.clientY - 50 + 'px';

function moveView(event) { = event.clientX - 50 + 'px'; = event.clientY - 50 + 'px';

function hideView(event) {
  view.setAttribute('hidden', '');

const container = document.querySelector('.container');
const view = document.querySelector('.view');

container.onmousedown = showView;
container.onmousemove = moveView;
document.onmouseup = hideView;



Specification Status Comment
HTML Living Standard
The definition of 'onmousedown' in that specification.
Living Standard  

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onmousedownChrome Full support YesEdge Full support YesFirefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes


Full support  
Full support

See also