From 95bcdac57c47b2b80f01de2c8fc822e483c9978c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 6 Apr 2014 13:02:52 +0200 Subject: [PATCH] Capture command + key combinations in key handling. Closes #379. --- src/ui/Key.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ui/Key.js b/src/ui/Key.js index f5cea964..bc7451d8 100644 --- a/src/ui/Key.js +++ b/src/ui/Key.js @@ -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 {