JavaScript: Check if mouse button down?

Regarding Pax’ solution: it doesn’t work if user clicks more than one button intentionally or accidentally. Don’t ask me how I know :-(. The correct code should be like that: var mouseDown = 0; document.body.onmousedown = function() { ++mouseDown; } document.body.onmouseup = function() { –mouseDown; } With the test like this: if(mouseDown){ // crikey! isn’t … Read more