From 4ee3a76a747f6a8bf33ec31c02771aad615c851e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 20 Dec 2015 11:32:16 +0100 Subject: [PATCH] Improve handling of special characters and control sequences. --- src/event/Key.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/event/Key.js b/src/event/Key.js index 8af273a5..3f611eb4 100644 --- a/src/event/Key.js +++ b/src/event/Key.js @@ -18,6 +18,7 @@ var Key = new function() { var keyLookup = { // Unify different naming scheme, e.g. Gecko, IE, ... ' ': 'space', + '\t': 'tab', 'Spacebar': 'space', 'Win': 'meta', 'Del': 'delete', @@ -155,8 +156,12 @@ var Key = new function() { keypress: function(event) { if (downKey) { - handleKey(true, downKey, String.fromCharCode(event.charCode), - event); + var code = event.charCode; + // Try event.charCode if its above 32 and fall back onto the + // key value if it's a single character, empty otherwise. + handleKey(true, downKey, code >= 32 + ? String.fromCharCode(code) + : downKey.length > 1 ? '' : downKey, event); downKey = null; } },