diff options
| author | gdh1995 | 2016-08-18 10:57:01 +0800 | 
|---|---|---|
| committer | gdh1995 | 2016-08-18 10:57:02 +0800 | 
| commit | f1c4f28536f3b5e2e0cc37c67d71f224504cce79 (patch) | |
| tree | e3a53b913814846b0e00163ef8eb04692599125f | |
| parent | aa178b03ea1e4d12071751b81be9237428e5a97e (diff) | |
| download | vimium-f1c4f28536f3b5e2e0cc37c67d71f224504cce79.tar.bz2 | |
support mapping <backspace>
Chrome stop using <backspace> to go back, but some still wants this
feature.
This should fix #2207 and #2214.
| -rw-r--r-- | background_scripts/commands.coffee | 4 | ||||
| -rw-r--r-- | lib/keyboard_utils.coffee | 3 | 
2 files changed, 5 insertions, 2 deletions
| diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index c334cf9d..f865131d 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -41,7 +41,7 @@ Commands =    # them you have to press "shift" as well.    normalizeKey: (key) ->      key.replace(/<[acm]-/ig, (match) -> match.toLowerCase()) -       .replace(/<([acm]-)?([a-zA-Z0-9]{2,5})>/g, (match, optionalPrefix, keyName) -> +       .replace(/<([acm]-)?([a-zA-Z0-9]{2,})>/g, (match, optionalPrefix, keyName) ->            "<" + (if optionalPrefix then optionalPrefix else "") + keyName.toLowerCase() + ">")    parseCustomKeyMappings: (customKeyMappings) -> @@ -97,7 +97,7 @@ Commands =      # Keys are either literal characters, or "named" - for example <a-b> (alt+b), <left> (left arrow) or <f12>      # This regular expression captures two groups: the first is a named key, the second is the remainder of      # the string. -    namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/ +    namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,})>)(.*)$/      keyStateMapping = {}      for own keys, registryEntry of @keyToCommandRegistry        currentMapping = keyStateMapping diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index f997b455..65c67ec0 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -49,6 +49,8 @@ KeyboardUtils =        event.key.toLowerCase() # F1 to F9.      else if event.key.length == 3 and "F10" <= event.key <= "F12"        event.key.toLowerCase() # F10 to F12. +    else if event.key.length > 3 and event.key in ["Backspace"] +      event.key.toLowerCase() # F10 to F12.      else        "" @@ -60,6 +62,7 @@ KeyboardUtils =        if (event.keyCode >= @keyCodes.f1 && event.keyCode <= @keyCodes.f12)          return "f" + (1 + event.keyCode - keyCodes.f1)        return "" +    return "backspace" if event.keyIdentifier == "U+0008"      keyIdentifier = event.keyIdentifier      # On Windows, the keyIdentifiers for non-letter keys are incorrect. See | 
