From 19d811b0f4b3c98e815d6ede8f491c71509786a1 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sun, 19 Jun 2016 10:46:53 -0400 Subject: [PATCH] Handle buggy keyboard events --- assets/javascripts/app/shortcuts.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/assets/javascripts/app/shortcuts.coffee b/assets/javascripts/app/shortcuts.coffee index 12656620..74f7b0f5 100644 --- a/assets/javascripts/app/shortcuts.coffee +++ b/assets/javascripts/app/shortcuts.coffee @@ -20,6 +20,7 @@ class app.Shortcuts @showTip = null onKeydown: (event) => + return if @buggyEvent(event) result = if event.ctrlKey or event.metaKey @handleKeydownSuperEvent event unless event.altKey or event.shiftKey else if event.shiftKey @@ -33,6 +34,7 @@ class app.Shortcuts return onKeypress: (event) => + return if @buggyEvent(event) unless event.ctrlKey or event.metaKey result = @handleKeypressEvent event event.preventDefault() if result is false @@ -148,3 +150,12 @@ class app.Shortcuts false else @lastKeypress = Date.now() + + buggyEvent: (event) -> + try + event.target + event.ctrlKey + event.which + return false + catch + return true