Created
August 18, 2023 10:09
-
-
Save RobinBoers/bd9096d2be254caec2f6dfd6666c642d to your computer and use it in GitHub Desktop.
Simple script for listening to all events for an element
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
let element = window; | |
Object.keys(window).forEach((key) => { | |
if (/^on/.test(key)) { | |
element.addEventListener(key.slice(2), (event) => { | |
if(event.type.includes("mouse") || event.type.includes("pointer") || event.type.includes("key")) return; | |
console.log(event); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment