diff options
| author | Stephen Blott | 2017-04-11 15:44:42 +0100 |
|---|---|---|
| committer | Stephen Blott | 2017-04-18 05:50:10 +0100 |
| commit | 44555e7863a66b906c47f0c94507d9e055922d3e (patch) | |
| tree | aafff85ca787b8c5d068cad7e2b063c40ddd7e06 /lib/dom_utils.coffee | |
| parent | 8058a54fd5a6a2f0e1a62a3a66f837a07045396e (diff) | |
| download | vimium-44555e7863a66b906c47f0c94507d9e055922d3e.tar.bz2 | |
Move keyboard utils to keydown and migrate normal/visual modes.
Diffstat (limited to 'lib/dom_utils.coffee')
| -rw-r--r-- | lib/dom_utils.coffee | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 690d9969..df9ca390 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -315,6 +315,25 @@ DomUtils = false handlerStack.suppressEvent + consumeKeyup: (event, callback = null) -> + @suppressEvent event + keyChar = KeyboardUtils.getKeyCharString event + handlerStack.push + _name: "dom_utils/consumeKeyup" + keydown: (event) -> + @remove() + handlerStack.continueBubbling + keyup: (event) -> + return handlerStack.continueBubbling unless keyChar == KeyboardUtils.getKeyCharString event + @remove() + handlerStack.suppressEvent + # We cannot track keyup events if we lose the focus. + blur: (event) -> + @remove() if event.target == window + handlerStack.continueBubbling + callback?() + handlerStack.suppressEvent + # Adapted from: http://roysharon.com/blog/37. # This finds the element containing the selection focus. getElementWithFocus: (selection, backwards) -> |
