diff options
| author | Stephen Blott | 2016-02-28 14:01:16 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-03-05 05:38:30 +0000 |
| commit | 520b63cb1d64fb5a293988122007bd05bacc49db (patch) | |
| tree | f3fd0d50edb493e24a543e6627bcd9c975e82c23 /content_scripts/mode_passkeys.coffee | |
| parent | cf7a03dc26415528bc690147ba72c08e67dd65c8 (diff) | |
| download | vimium-520b63cb1d64fb5a293988122007bd05bacc49db.tar.bz2 | |
Key bindings; fix tests...
... and fix two bugs:
- not suppressing keyup event after keyChar matched in keydown.
- we cannot check the passKeys keyChar in keyup because the key state
has changed; so we track what the next keyup response should be.
Diffstat (limited to 'content_scripts/mode_passkeys.coffee')
| -rw-r--r-- | content_scripts/mode_passkeys.coffee | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/content_scripts/mode_passkeys.coffee b/content_scripts/mode_passkeys.coffee index a68fe3be..7efa559c 100644 --- a/content_scripts/mode_passkeys.coffee +++ b/content_scripts/mode_passkeys.coffee @@ -1,12 +1,15 @@ class PassKeysMode extends Mode constructor: (@normalMode) -> + @nextKeyup = @continueBubbling super name: "passkeys" trackState: true # Maintain @passKeys. keydown: (event) => @handleKeyChar event, KeyboardUtils.getKeyChar event keypress: (event) => @handleKeyChar event, String.fromCharCode event.charCode - keyup: (event) => @handleKeyChar event, KeyboardUtils.getKeyChar event + keyup: => ([_, @nextKeyup] = [@nextKeyup, @continueBubbling])[0] + # We cannot track keyup events if we lose the focus. + blur: (event) => @alwaysContinueBubbling => @nextKeyup = @continueBubbling if event.target == window # Keystrokes are *never* considered passKeys if the user has begun entering a command. So, for example, if # 't' is a passKey, then 'gt' and '99t' are neverthless be handled by Vimium. @@ -14,7 +17,7 @@ class PassKeysMode extends Mode return @continueBubbling if event.altKey or event.ctrlKey or event.metaKey return @continueBubbling unless keyChar and @normalMode.isFirstKeyChar keyChar return @continueBubbling unless keyChar.length == 1 and 0 <= @passKeys.indexOf keyChar - @stopBubblingAndTrue + @nextKeyup = @stopBubblingAndTrue root = exports ? window root.PassKeysMode = PassKeysMode |
