I was trying to detect, if mouse is pressed while moving over CANVAS:
canvas.addEventListener('mousemove', function (evt) {
...
});
Setting a flag inside mousedown and skipping it in mouseup is a bad idea, because user can release mouse button outside the canvas.
evt.which
will be 1
if left mouse button is held down during the fired mousemove event, 0
if it's not.
Test with:
document.addEventListener("mousemove", function (e) {
console.log(e.which);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.