Last active
February 18, 2023 05:04
-
-
Save matthewpizza/1844cb88925eef8c75c5 to your computer and use it in GitHub Desktop.
Safari’s weird mousemove — the event fires when hitting modifier keys `ctrlKey`, `shiftKey`, `altKey`, and `metaKey` https://matthewspencer.github.io/mouse-move-in-safari/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener('mousemove', function (event) { | |
console.log(event.type); | |
}, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lastClientX; | |
var lastClientY; | |
document.addEventListener('mousemove', function (event) { | |
if (lastClientX === event.clientX && lastClientY === event.clientY) { | |
return; | |
} | |
lastClientX = event.clientX; | |
lastClientY = event.clientY; | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment