diff options
| author | Stephen Blott | 2016-10-02 09:01:29 +0100 |
|---|---|---|
| committer | Stephen Blott | 2016-10-02 09:22:09 +0100 |
| commit | 967aa7bf31998f667616f19f9b83e409340b66d1 (patch) | |
| tree | 590b3fde8de04a9e29ccdd84eff7015c169dcf37 /lib/keyboard_utils.coffee | |
| parent | d439a13afd1569548e62def33278f31b258984db (diff) | |
| download | vimium-967aa7bf31998f667616f19f9b83e409340b66d1.tar.bz2 | |
Rework key-sequence parsing.
This reworks the parsing of key sequences like `<c-a-Z>x`:
Advantages over the status quo:
- Parses key sequences in one only place (previously two),
- Removes two hideous regular expression.
- Admits multi-modifier bindings (like `<c-a-Z>`).
- Adds more (and better) tests.
- (And it should be easier to maintain.)
Replaces #2210 (this also simplifies key parsing substantially).
Diffstat (limited to 'lib/keyboard_utils.coffee')
| -rw-r--r-- | lib/keyboard_utils.coffee | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index dabf864d..f0e791d4 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -111,9 +111,10 @@ KeyboardUtils = modifiers = [] keyChar = keyChar.toUpperCase() if event.shiftKey - modifiers.push "m" if event.metaKey - modifiers.push "c" if event.ctrlKey + # These must be in alphabetical order (to match the sorted modifier order in Commands.normalizeKey). modifiers.push "a" if event.altKey + modifiers.push "c" if event.ctrlKey + modifiers.push "m" if event.metaKey keyChar = [modifiers..., keyChar].join "-" if 1 < keyChar.length then "<#{keyChar}>" else keyChar |
