From 40a7509286a87911ad4cc06d9482e8a2e5d0e7e8 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Tue, 9 Jul 2024 21:38:25 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A8=98=E9=8C=B2=E3=81=99=E3=82=8B=E3=83=9B?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=82=AD=E3=83=BC=E3=81=AF=E3=83=AC=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=83=AA=E3=83=9F=E3=83=83=E3=83=88=E5=BC=8F=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/scripts/hotkey.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/frontend/src/scripts/hotkey.ts b/packages/frontend/src/scripts/hotkey.ts index 073d41626384..4581d8835295 100644 --- a/packages/frontend/src/scripts/hotkey.ts +++ b/packages/frontend/src/scripts/hotkey.ts @@ -131,7 +131,13 @@ const matchPatterns = (ev: KeyboardEvent, action: Action) => { }); }; +let lastHotKeyStoreTimer: number | null = null; + const storePattern = (ev: KeyboardEvent, callback: CallbackFunction) => { + if (lastHotKeyStoreTimer != null) { + clearTimeout(lastHotKeyStoreTimer); + } + latestHotkey = { which: [ev.key.toLowerCase()], ctrl: ev.ctrlKey || ev.metaKey, @@ -139,6 +145,10 @@ const storePattern = (ev: KeyboardEvent, callback: CallbackFunction) => { shift: ev.shiftKey, callback, }; + + lastHotKeyStoreTimer = window.setTimeout(() => { + latestHotkey = null; + }, 500); }; const parseKeyCode = (input?: string | null) => {