From dab8d6cd5d48eb6f80a9e93b377dbce1b28b32e1 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Mon, 9 Oct 2023 00:52:06 +0200 Subject: [PATCH] Don't ignore escape if a textfield is selected --- src/UI/Base/Hotkeys.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/UI/Base/Hotkeys.ts b/src/UI/Base/Hotkeys.ts index 6b4f07365..e40d92166 100644 --- a/src/UI/Base/Hotkeys.ts +++ b/src/UI/Base/Hotkeys.ts @@ -22,7 +22,14 @@ export default class Hotkeys { }[] >([]) - private static textElementSelected(): boolean { + private static textElementSelected(event: KeyboardEvent): boolean { + if(event.ctrlKey || event.altKey){ + // This is an event with a modifier-key, lets not ignore it + return false + } + if(event.key === "Escape"){ + return false // Another not-printable character that should not be ignored + } return ["input", "textarea"].includes(document?.activeElement?.tagName?.toLowerCase()) } public static RegisterHotkey( @@ -68,7 +75,7 @@ export default class Hotkeys { }) } else if (key["shift"] !== undefined) { document.addEventListener(type, function (event) { - if (Hotkeys.textElementSelected()) { + if (Hotkeys.textElementSelected(event)) { // A text element is selected, we don't do anything special return } @@ -86,7 +93,7 @@ export default class Hotkeys { }) } else if (key["nomod"] !== undefined) { document.addEventListener(type, function (event) { - if (Hotkeys.textElementSelected()) { + if (Hotkeys.textElementSelected(event)) { // A text element is selected, we don't do anything special return }