Table of Contents

About

The mousedown event occurs when the pointing device button is pressed.

It also occurs when a click occurs

Example

OnMouseDown

event handler content attribute (ie on HTML attribute

<button class="btn btn-info" onmousedown="console.log('Mouse Down!')" >Click Me</button>

Mouse Down Event Listener

Example of DOM - Event Listener function with the mousedown event.

  • The Javascript
document.querySelector('button').addEventListener("mousedown", event => { 
        console.log('Mouse down !'); 
}
);
  • The HTML
<button>Poke me!</button>