How to check the current mouse button state Using Javascript [duplicate]
问题 This question already has answers here : JavaScript: Check if mouse button down? (16 answers) Closed 3 years ago . I want the state of mouse on Down state or on up state document.onmousemove = mouseMove; document.onmousedown = mouseDown; document.onmouseup = mouseUp; function mouseMove(ev) { mouseState=""; //How can I know the state button of mouse button from here if(mouseState=='down') { console.log('mouse down state') } if(mouseState=='up') { console.log('mouse up state') } } function