aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Crosby2009-12-31 02:01:04 -0500
committerPhil Crosby2009-12-31 02:01:04 -0500
commita8b0a87252fde722eae1672409bee30bf79c1bbb (patch)
tree33c1043b3f90c16c4d4a86d9bca9ccc532ac1505
parent7890bf8e6be5a7855066ae964e827545d8eb5423 (diff)
downloadvimium-a8b0a87252fde722eae1672409bee30bf79c1bbb.tar.bz2
Enter insert mode when any form element is focused. Fixes #36 and #27.
-rw-r--r--vimiumFrontend.js10
1 files 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() {