From c4cc76e9f6a0a99ebc297e420be739a0fc77f827 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 5 Nov 2017 07:49:13 +0000 Subject: Add more named keys (version 2) This allows any special key to mapped, simply by using the `event.key` key name. E.g. map scrollDown Replaces #2770. Fixes #2769. --- lib/keyboard_utils.coffee | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index 681ee139..8cd2a490 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -5,7 +5,7 @@ Utils?.monitorChromeStorage "mapKeyRegistry", (value) => mapKeyRegistry = value KeyboardUtils = # This maps event.key key names to Vimium key names. keyNames: - "ArrowLeft": "left", "ArrowUp": "up", "ArrowRight": "right", "ArrowDown": "down", " ": "space", "Backspace": "backspace" + "ArrowLeft": "left", "ArrowUp": "up", "ArrowRight": "right", "ArrowDown": "down", " ": "space" init: -> if (navigator.userAgent.indexOf("Mac") != -1) @@ -38,10 +38,8 @@ KeyboardUtils = "" else if key.length == 1 key - else if key.length == 2 and "F1" <= key <= "F9" - key.toLowerCase() # F1 to F9. - else if key.length == 3 and "F10" <= key <= "F12" - key.toLowerCase() # F10 to F12. + else if 1 < key.length + key.toLowerCase() else "" -- cgit v1.2.3