Keyboard Shortcut String
Creates a canonical keyboard shortcut string from the given shortcut string input.
This module does not bind shortcuts to keyboard events – its only job is to
parse shortcut strings, and return predictable results. A good use for this
module would be to support a keystroke module's event handler mapping.
Examples:
console.log(getCanonicalShortcut('ctrl s'));
console.log(getCanonicalShortcut('s ctrl'));
console.log(getCanonicalShortcut('s ctrl'));
console.log(getCanonicalShortcut('shift ctrl s'));
console.log(getCanonicalShortcut('ctrl shift s'));
console.log(getCanonicalShortcut('S CTRL SHIFT'));
Modifier Keys
Modifier keys are extracted from the input and placed in a predictable order at
the front of the result.
Non-modifier Keys
Only one non-modifier key component is allowed: "alt s" works, but "alt s h"
will throw.
Non-modifier keys can be almost anything: "s", "S", "space", "ESC", and lowercase
is always returned.
Thanks!
This source is heavily sourced from MooTools Keyboard.parse.
License
MIT