Capture command + key combinations in key handling.

Closes #379.
This commit is contained in:
Jürg Lehni 2014-04-06 13:02:52 +02:00
parent 6ddf112b39
commit 95bcdac57c

View file

@ -40,7 +40,7 @@ var Key = new function() {
224: 'command' // Gecko command button
},
// Mark the special skeys that still can be interpreted as chars too
// Mark the special keys that still can be interpreted as chars too
specialChars = {
9: true, // tab
13: true, // enter
@ -107,10 +107,15 @@ var Key = new function() {
// If the keyCode is in keys, it needs to be handled by keydown and
// not in keypress after (arrows for example wont be triggering
// a keypress, but space would).
if (code in specialKeys) {
// No char code for special keys (except the ones listed in
// specialChars), but mark as pressed by setting to 0.
handleKey(true, code, code in specialChars ? code : 0, event);
// The same applies when pressing the command / meta key, as we
// won't get a keypress event for these combos.
if (code in specialKeys || modifiers.command) {
handleKey(true, code,
// No char code for special keys (except the ones listed
// in specialChars, or when pressing command modifier),
// but mark as pressed by setting to 0.
code in specialChars || modifiers.command ? code : 0,
event);
// Do not set downCode as we handled it already. Space would
// be handled twice otherwise, once here, once in keypress.
} else {