diff options
| author | Jez Ng | 2012-01-22 00:39:13 -0500 |
|---|---|---|
| committer | Jez Ng | 2012-01-26 02:48:00 -0500 |
| commit | b8789c56b0ee96ee1eca75291028017c4f9d89cc (patch) | |
| tree | e236fa46d36a0844f4ff1e176b5cbff1112866de /vimiumFrontend.js | |
| parent | ff8ebd2eadb68ca9fb2b75273f03b9c1706fc969 (diff) | |
| download | vimium-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.js | 9 |
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. |
