mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Improve handling of special characters and control sequences.
This commit is contained in:
parent
0346552bc6
commit
4ee3a76a74
1 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue