Reputation: 21
Is there a jQuery event that fires only while holding down left mouse botton ?
I have tried the .mousedown() event but it doesn't seems to work for me.
Upvotes: 0
Views: 411
Reputation: 1804
The button value in available in the mouse event. The buttons are numbered from the primary button at value 0 and upward. Look at this example.
const div = document.getElementById('log');
document.addEventListener('mousedown', function(e) {
div.innerHTML+= ' '+e.button;
});
div {
border: 1px solid #000;
padding: 3px 5px;
min-height: 1.5em;
}
<div id="log"></div>
Upvotes: 1