Skip to content

Instantly share code, notes, and snippets.

@pongo
Created July 28, 2025 07:38
Show Gist options
  • Save pongo/07de1a81b68492004cba6bbc3d4afddc to your computer and use it in GitHub Desktop.
Save pongo/07de1a81b68492004cba6bbc3d4afddc to your computer and use it in GitHub Desktop.
export function prevent<T extends unknown[], R>(listener: (event: KeyboardEvent, ...rest: T) => R) {
return (event: KeyboardEvent, ...rest: T) => {
event.preventDefault();
event.stopPropagation();
return listener(event, ...rest);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment