Skip to content

Instantly share code, notes, and snippets.

@matthewpizza
Last active February 18, 2023 05:04
Show Gist options
  • Save matthewpizza/1844cb88925eef8c75c5 to your computer and use it in GitHub Desktop.
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/
document.addEventListener('mousemove', function (event) {
console.log(event.type);
}, false);
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