aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dom_utils.coffee
diff options
context:
space:
mode:
authorStephen Blott2017-04-11 15:44:42 +0100
committerStephen Blott2017-04-18 05:50:10 +0100
commit44555e7863a66b906c47f0c94507d9e055922d3e (patch)
treeaafff85ca787b8c5d068cad7e2b063c40ddd7e06 /lib/dom_utils.coffee
parent8058a54fd5a6a2f0e1a62a3a66f837a07045396e (diff)
downloadvimium-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.coffee19
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) ->