Skip to content

Instantly share code, notes, and snippets.

@Bamieh
Created Oct 19, 2016
Embed
What would you like to do?
Tiny Crossbrowser Keycode checking function
/*
usage:
Events.on(window, 'keydown', (event) => {
tabPressed = keycode(event, 13);
});
*/
export default function keycode(event, code) {
const property = event.key || event.keyIdentifier || event.keyCode;
return property && property === code;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment