aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/link_hints.coffee1
-rw-r--r--content_scripts/mode.coffee19
-rw-r--r--lib/handler_stack.coffee2
3 files changed, 21 insertions, 1 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index a5e94fd0..cdd2dfac 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -69,6 +69,7 @@ class LinkHintsMode
indicator: false
passInitialKeyupEvents: true
suppressAllKeyboardEvents: true
+ suppressTrailingKeyEvents: true
exitOnEscape: true
exitOnClick: true
exitOnScroll: true
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 508b1b2c..49da03e2 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -144,6 +144,25 @@ class Mode
keyup: (event) =>
if KeyboardUtils.isPrintable event then @stopBubblingAndFalse else @stopBubblingAndTrue
+ # if @options.suppressTrailingKeyEvents is set, then we suppress all key events until a subsquent
+ # (non-repeat) keydown or keypress. In particular, the intention is to catch keyup events for keys which
+ # we have handled, but which otherwise might trigger page actions (if the page is listening for keyup
+ # events).
+ if @options.suppressTrailingKeyEvents
+ @onExit ->
+ handler = (event) ->
+ if event.repeat
+ false # Suppress event.
+ else
+ keyEventSuppressor.exit()
+ true # Do not suppress event.
+
+ keyEventSuppressor = new Mode
+ name: "suppress-trailing-key-events"
+ keydown: handler
+ keypress: handler
+ keyup: -> handlerStack.stopBubblingAndFalse
+
Mode.modes.push @
@setIndicator()
@logModes()
diff --git a/lib/handler_stack.coffee b/lib/handler_stack.coffee
index b09d3183..c07d028b 100644
--- a/lib/handler_stack.coffee
+++ b/lib/handler_stack.coffee
@@ -48,7 +48,7 @@ class HandlerStack
result = handler[type].call @, event
@logResult eventNumber, type, event, handler, result if @debug
if not result
- DomUtils.suppressEvent event if @isChromeEvent event
+ DomUtils.suppressEvent event if @isChromeEvent event
return false
return true if result == @stopBubblingAndTrue
return false if result == @stopBubblingAndFalse