Skip to content

Instantly share code, notes, and snippets.

@a7madgamal
Created August 29, 2023 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a7madgamal/81eb4a2fe1826eefc880364a6866eb52 to your computer and use it in GitHub Desktop.
Save a7madgamal/81eb4a2fe1826eefc880364a6866eb52 to your computer and use it in GitHub Desktop.
listen to all js events
Object.keys(window).forEach((key) => {
if (/^on/.test(key)) {
const name = key.slice(2);
console.log(name);
window.addEventListener(name, (event) => {
const tag = event[Symbol.toStringTag];
// exclude noisy ones
if (!['TransitionEvent', 'MouseEvent', 'PointerEvent', 'AnimationEvent'].includes(tag)) {
console.log(event);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment