From f29a8ef0f707a9c9a9168b7f1177dda771a802c9 Mon Sep 17 00:00:00 2001 From: Clemens Zeidler Date: Sun, 28 Feb 2021 20:12:36 +1300 Subject: [PATCH] Handle shift + letter combos --- src/KeyBindingsManager.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/KeyBindingsManager.ts b/src/KeyBindingsManager.ts index ef5084c16c..e26950b862 100644 --- a/src/KeyBindingsManager.ts +++ b/src/KeyBindingsManager.ts @@ -264,8 +264,17 @@ const autocompleteBindings = (): KeyBinding[] => { * Note, this method is only exported for testing. */ export function isKeyComboMatch(ev: KeyboardEvent | React.KeyboardEvent, combo: KeyCombo, onMac: boolean): boolean { - if (combo.key !== undefined && ev.key !== combo.key) { - return false; + if (combo.key !== undefined) { + // When shift is pressed, letters are returned as upper case chars. In this case do a lower case comparison. + // This works for letter combos such as shift + U as well for none letter combos such as shift + Escape. + // If shift is not pressed, the toLowerCase conversion can be avoided. + if (ev.shiftKey) { + if (ev.key.toLowerCase() !== combo.key.toLowerCase()) { + return false; + } + } else if (ev.key !== combo.key) { + return false; + } } const comboCtrl = combo.ctrlKey ?? false;