Created
October 26, 2018 13:22
-
-
Save SilencerWeb/4ff6e22145cf2400da9e5510046ece87 to your computer and use it in GitHub Desktop.
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
handleKeyUp = (e) => { | |
let shortcut = []; | |
if (e.ctrlKey) { | |
shortcut.push('Ctrl'); | |
} | |
if (e.metaKey) { | |
shortcut.push('Command'); | |
} | |
if (e.shiftKey) { | |
shortcut.push('Shift'); | |
} | |
if (e.altKey) { | |
shortcut.push('Alt'); | |
} | |
if (shortcut.length === 0 || shortcut.length > 2) return; | |
if (e.keyCode < 65 || e.keyCode > 90) return; | |
shortcut.push(e.key); | |
shortcut = shortcut.join('+'); | |
console.log('valid shortcut', shortcut); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment