diff --git a/src/command/KeyMap.js b/src/command/KeyMap.js index 6e5418967b5..4f469871a9a 100644 --- a/src/command/KeyMap.js +++ b/src/command/KeyMap.js @@ -66,6 +66,19 @@ define(function (require, exports, module) { return keyDescriptor.join("-"); } + function _isModifier(left, right, previouslyFound, origDescriptor) { + if (!left || !right) { + return false; + } + left = left.trim().toLowerCase(); + right = right.trim().toLowerCase(); + var matched = (left.length > 0 && left === right); + if (matched && previouslyFound) { + console.log("KeyMap _normalizeKeyDescriptorString() - Modifier defined twice: " + origDescriptor); + } + return matched; + } + /** * @private * normalizes the incoming key descriptor so the modifier keys are always specified in the correct order @@ -78,31 +91,18 @@ define(function (require, exports, module) { hasShift = false, key = ""; - function _isModifier(left, right, previouslyFound) { - if (!left || !right) { - return false; - } - left = left.trim().toLowerCase(); - right = right.trim().toLowerCase(); - var matched = (left.length > 0 && left === right); - if (matched && previouslyFound) { - console.log("KeyMap _normalizeKeyDescriptorString() - Modifier defined twice: " + origDescriptor); - } - return matched; - } - origDescriptor.split("-").forEach(function parseDescriptor(ele, i, arr) { if (_isModifier("ctrl", ele, hasCtrl)) { hasCtrl = true; - } else if (_isModifier("cmd", ele, hasCtrl)) { + } else if (_isModifier("cmd", ele, hasCtrl, origDescriptor)) { console.log("KeyMap _normalizeKeyDescriptorString() - Cmd getting mapped to Ctrl from: " + origDescriptor); hasCtrl = true; - } else if (_isModifier("alt", ele, hasAlt)) { + } else if (_isModifier("alt", ele, hasAlt, origDescriptor)) { hasAlt = true; - } else if (_isModifier("opt", ele, hasAlt)) { + } else if (_isModifier("opt", ele, hasAlt, origDescriptor)) { console.log("KeyMap _normalizeKeyDescriptorString() - Opt getting mapped to Alt from: " + origDescriptor); hasAlt = true; - } else if (_isModifier("shift", ele, hasShift)) { + } else if (_isModifier("shift", ele, hasShift, origDescriptor)) { hasShift = true; } else if (key.length > 0) { console.log("KeyMap _normalizeKeyDescriptorString() - Multiple keys defined. Using key: " + key + " from: " + origDescriptor);