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 = {
|
var keyLookup = {
|
||||||
// Unify different naming scheme, e.g. Gecko, IE, ...
|
// Unify different naming scheme, e.g. Gecko, IE, ...
|
||||||
' ': 'space',
|
' ': 'space',
|
||||||
|
'\t': 'tab',
|
||||||
'Spacebar': 'space',
|
'Spacebar': 'space',
|
||||||
'Win': 'meta',
|
'Win': 'meta',
|
||||||
'Del': 'delete',
|
'Del': 'delete',
|
||||||
|
@ -155,8 +156,12 @@ var Key = new function() {
|
||||||
|
|
||||||
keypress: function(event) {
|
keypress: function(event) {
|
||||||
if (downKey) {
|
if (downKey) {
|
||||||
handleKey(true, downKey, String.fromCharCode(event.charCode),
|
var code = event.charCode;
|
||||||
event);
|
// 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;
|
downKey = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue