From 24857624ff106b638fd86d3219031fd5629a824a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 3 Mar 2016 07:38:31 -0800 Subject: [PATCH] Fixed double-Ctrl shortcut in text fields on Ubuntu Inside text fields on Ubuntu, keydown and keyup events report ctrlKey as false, even when the key in question is DOM_VK_CONTROL. Fixes #167. --- content/avim.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/avim.js b/content/avim.js index 6ed0c20..f9c2ed6 100644 --- a/content/avim.js +++ b/content/avim.js @@ -597,8 +597,8 @@ function AVIM() { //dump("AVIM.onKeyDown -- code: " + String.fromCharCode(e.which) + " #" + e.which + // "; target: " + e.target.nodeName + "." + e.target.className + "#" + e.target.id + // "; originalTarget: " + e.originalTarget.nodeName + "." + e.originalTarget.className + "#" + e.originalTarget.id + "\n"); // debug - if (e.which === e.DOM_VK_CONTROL && e.ctrlKey && !e.metaKey && - !e.altKey && !e.shiftKey && + if (e.which === e.DOM_VK_CONTROL && !e.metaKey && !e.altKey && + !e.shiftKey && !(this.numCtrlPresses && this.ctrlStartDate && // GetDoubleClickTime() on Windows: ?–5 s, default 500 ms // +[NSEvent doubleClickInterval] on OS X: 150 ms–5 s, default 500 ms @@ -637,8 +637,8 @@ function AVIM() { if (avim && avim.isWaitingForCtrlKeyUp) { avim.isWaitingForCtrlKeyUp = false; if (!avim.ctrlStartDate) avim.ctrlStartDate = new Date(); - if (e.which === e.DOM_VK_CONTROL && !e.ctrlKey && !e.metaKey && - !e.altKey && !e.shiftKey) { + if (e.which === e.DOM_VK_CONTROL && !e.metaKey && !e.altKey && + !e.shiftKey) { if (++avim.numCtrlPresses > 1) { avim.stopListeningForCtrl(); avim.toggle(true);