diff options
| author | Conrad Irwin | 2010-05-29 16:09:17 +0100 |
|---|---|---|
| committer | Phil Crosby | 2010-06-01 21:55:55 -0700 |
| commit | 8893e55daec12693197e4550a75f28885f47760f (patch) | |
| tree | a47e0d0e6b3d1863471a9b1d521f851850322e7c /commands.js | |
| parent | 9d0061dca6101926da760e159d50151984ae24f8 (diff) | |
| download | vimium-8893e55daec12693197e4550a75f28885f47760f.tar.bz2 | |
Document named key functions (per philc)
Diffstat (limited to 'commands.js')
| -rw-r--r-- | commands.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/commands.js b/commands.js index 8e4922f3..de6ce701 100644 --- a/commands.js +++ b/commands.js @@ -23,9 +23,20 @@ function mapKeyToCommand(key, command) { function unmapKey(key) { delete keyToCommandRegistry[key]; } +/* Lower-case the appropriate portions of named keys. + * + * A key name is one of three forms exemplified by <c-a> <left> or <c-f12> + * (prefixed normal key, named key, or prefixed named key). Internally, for + * simplicity, we would like prefixes and key names to be lowercase, though + * humans may prefer other forms <Left> or <C-a>. + * On the other hand, <c-a> and <c-A> are different named keys - for one of + * them you have to press "shift" as well. + */ function normalizeKey(key) { - return key.replace(/<[amc]-/i, function(m){return m.toLowerCase();}) - .replace(/<([acm]-)?([a-zA-Z0-9]+)>/, function(m, p, k){return "<" + (p ? p : "") + k.toLowerCase() + ">";}); + return key.replace(/<[acm]-/ig, function(match){ return match.toLowerCase(); }) + .replace(/<([acm]-)?([a-zA-Z0-9]{2,5})>/g, function(match, optionalPrefix, keyName){ + return "<" + ( optionalPrefix ? optionalPrefix : "") + keyName.toLowerCase() + ">"; + }); } function parseCustomKeyMappings(customKeyMappings) { |
