I’m writing an HTML5 canvas drawing app, and I need to be able to tell whether or not the left mouse button is pressed down during a mousemove event. On Chrome, this works:
if (event.which == 1) { <do stuff> }
But in FireFox, event.which always is 1, no matter whether or not the button is pressed.
How can I detect whether the mouse button is pressed during a mousemove event?
In short, you can’t. MDN, for example, explains:
If you want, you can set global
mousedownandmouseuphandlers that set flags appropriately and then at any given point in time you can with relative degree of accuracy determine if/which mouse button is pressed.