From a8b0a87252fde722eae1672409bee30bf79c1bbb Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Thu, 31 Dec 2009 02:01:04 -0500 Subject: Enter insert mode when any form element is focused. Fixes #36 and #27. --- vimiumFrontend.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/vimiumFrontend.js b/vimiumFrontend.js index e3c0c7de..d3345053 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -289,9 +289,15 @@ function onBlurCapturePhase(event) { */ function isFocusable(element) { return isInputOrText(element) || element.tagName == "EMBED"; } +/* + * Input or text elements are considered focusable and able to receieve their own keyboard events, + * and will enter enter mode if focused. + * Note: we used to discriminate for text-only inputs, but this is not accurate since all input fields + * can be controlled via the keyboard, particuarlly SELECT combo boxes. + */ function isInputOrText(target) { - return ((target.tagName == "INPUT" && (target.type == "text" || target.type == "password")) || - target.tagName == "TEXTAREA"); + var focusableInputs = ["input", "textarea", "select", "button"]; + return focusableInputs.indexOf(target.tagName.toLowerCase()) >= 0; } function enterInsertMode() { -- cgit v1.2.3