Created
October 26, 2018 11:23
-
-
Save SilencerWeb/9ac5d670f03045147767b9fb8515b77c 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 = ''; | |
let modifiersCount = 0; | |
if (e.ctrlKey) { | |
shortcut += 'Ctrl '; | |
modifiersCount++; | |
} | |
if (e.metaKey) { | |
shortcut += 'Command '; | |
modifiersCount++; | |
} | |
if (e.shiftKey) { | |
shortcut += 'Shift '; | |
modifiersCount++; | |
} | |
if (e.altKey) { | |
shortcut += 'Alt '; | |
modifiersCount++; | |
} | |
shortcut += e.key; | |
shortcut = shortcut.split(' ').join('+'); | |
if (modifiersCount === 0 || modifiersCount > 2) return; | |
if (e.keyCode < 65 || e.keyCode > 90) return; | |
console.log('valid shortcut'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment