From 87ff762270239a605172bd02921afe43295cc74c Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Wed, 26 Jan 2011 07:34:46 +0800 Subject: [PATCH] Pulling in jviereck's fixes for keyboard handling. --- lib/ace/keyboard/state_handler.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/ace/keyboard/state_handler.js b/lib/ace/keyboard/state_handler.js index ab50bc74..5861ad23 100644 --- a/lib/ace/keyboard/state_handler.js +++ b/lib/ace/keyboard/state_handler.js @@ -80,13 +80,13 @@ StateHandler.prototype = { } var keyArray = []; - if (hashId & 1) keyArray.push("Ctrl"); - if (hashId & 8) keyArray.push("Command"); - if (hashId & 2) keyArray.push("Option"); - if (hashId & 4) keyArray.push("Shift"); + if (hashId & 1) keyArray.push("ctrl"); + if (hashId & 8) keyArray.push("command"); + if (hashId & 2) keyArray.push("option"); + if (hashId & 4) keyArray.push("shift"); if (key) keyArray.push(key); - var symbolicName = keyArray.join("-").toLowerCase(); + var symbolicName = keyArray.join("-"); var bufferToUse = data.buffer + symbolicName; // Don't add the symbolic name to the key buffer if the alt_ key is @@ -194,6 +194,13 @@ StateHandler.prototype = { * This function is called by keyBinding. */ handleKeyboard: function(data, hashId, key) { + // If we pressed any command key but no other key, then ignore the input. + // Otherwise "shift-" is added to the buffer, and later on "shift-g" + // which results in "shift-shift-g" which doesn't make senese. + if (hashId != 0 && (key == "" || String.fromCharCode(0))) { + return null; + } + // Compute the current value of the keyboard input buffer. var r = this.$composeBuffer(data, hashId, key); var buffer = r.bufferToUse;