diff options
| author | ilya | 2010-03-07 14:43:59 -0800 |
|---|---|---|
| committer | ilya | 2010-03-07 14:43:59 -0800 |
| commit | 96ae6f843b3d2f03122290fb26c2a9a4db1955cd (patch) | |
| tree | c7cebbade5d9804bd4b00ff4c5f875f904249dbb /vimiumFrontend.js | |
| parent | 4c32225f98cb6bf56f87834bef92f5c64476a90a (diff) | |
| download | vimium-96ae6f843b3d2f03122290fb26c2a9a4db1955cd.tar.bz2 | |
Handle shift for non-letter keys that are affected by the WebKit bug under Windows/Linux. This closes issue #84.
Diffstat (limited to 'vimiumFrontend.js')
| -rw-r--r-- | vimiumFrontend.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 9ad7c7e0..f3259f10 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -30,20 +30,18 @@ var currentZoomLevel = 100; // This is a mapping of the incorrect keyIdentifiers generated by Webkit on Windows during keydown events to // the correct identifiers, which are correctly generated on Mac. We require this mapping to properly handle // these keys on Windows. See https://bugs.webkit.org/show_bug.cgi?id=19906 for more details. -// TODO(philc): Currently we cannot distinguish between e.g. ",<"; we'll need to look at the keyboard event's -// shift key to do so on Windows. var keyIdentifierCorrectionMap = { - "U+00C0": "U+0060", // `~ - "U+00BD": "U+002D", // -_ - "U+00BB": "U+003D", // =+ - "U+00DB": "U+005B", // [{ - "U+00DD": "U+005D", // ]} - "U+00DC": "U+005C", // \| - "U+00BA": "U+003B", // ;: - "U+00DE": "U+0027", // '" - "U+00BC": "U+002C", // ,< - "U+00BE": "U+002E", // .> - "U+00BF": "U+002F" // /? + "U+00C0": ["U+0060", "U+007E"], // `~ + "U+00BD": ["U+002D", "U+005F"], // -_ + "U+00BB": ["U+003D", "U+002B"], // =+ + "U+00DB": ["U+005B", "U+007B"], // [{ + "U+00DD": ["U+005D", "U+007D"], // ]} + "U+00DC": ["U+005C", "U+007C"], // \| + "U+00BA": ["U+003B", "U+003A"], // ;: + "U+00DE": ["U+0027", "U+0022"], // '" + "U+00BC": ["U+002C", "U+003C"], // ,< + "U+00BE": ["U+002E", "U+003E"], // .> + "U+00BF": ["U+002F", "U+003F"] // /? }; function getSetting(key) { @@ -246,8 +244,10 @@ function getKeyChar(event) { var keyIdentifier = event.keyIdentifier; // On Windows, the keyIdentifiers for non-letter keys are incorrect. See // https://bugs.webkit.org/show_bug.cgi?id=19906 for more details. - if (platform == "Windows" || platform == "Linux") - keyIdentifier = keyIdentifierCorrectionMap[keyIdentifier] || keyIdentifier; + if ((platform == "Windows" || platform == "Linux") && keyIdentifierCorrectionMap[keyIdentifier]) { + correctedIdentifiers = keyIdentifierCorrectionMap[keyIdentifier]; + keyIdentifier = event.shiftKey ? correctedIdentifiers[1] : correctedIdentifiers[0]; + } var unicodeKeyInHex = "0x" + keyIdentifier.substring(2); return String.fromCharCode(parseInt(unicodeKeyInHex)).toLowerCase(); } |
