Skip to content

Commit

Permalink
Fixed double-Ctrl shortcut in text fields on Ubuntu
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
1ec5 committed Mar 3, 2016
1 parent a6fed66 commit 2485762
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions content/avim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2485762

Please sign in to comment.