aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorJez Ng2012-01-22 00:39:13 -0500
committerJez Ng2012-01-26 02:48:00 -0500
commitb8789c56b0ee96ee1eca75291028017c4f9d89cc (patch)
treee236fa46d36a0844f4ff1e176b5cbff1112866de /vimiumFrontend.js
parentff8ebd2eadb68ca9fb2b75273f03b9c1706fc969 (diff)
downloadvimium-b8789c56b0ee96ee1eca75291028017c4f9d89cc.tar.bz2
Make <ESC> do defocusing.
Vimium will try to blur the active element first. If there is no element to be blurred, we select the topmost frame instead. Thus the user is able to use <ESC> to return Vimium fully to its 'default' state. Closes #426.
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 6a3fd698..a175f0eb 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -510,6 +510,8 @@ function onKeydown(event) {
}
else if (isEscape(event)) {
keyPort.postMessage({keyChar:"<ESC>", frameId:frameId});
+ handleEscapeForNormalMode();
+ suppressEvent(event);
}
}
@@ -980,6 +982,13 @@ function hideHelpDialog(clickEvent) {
clickEvent.preventDefault();
}
+function handleEscapeForNormalMode() {
+ if (document.activeElement !== document.body)
+ document.activeElement.blur();
+ else if (window.top !== window.self)
+ chrome.extension.sendRequest({ handler: "focusTopFrame" });
+}
+
/*
* A heads-up-display (HUD) for showing Vimium page operations.
* Note: you cannot interact with the HUD until document.body is available.