From e805fef88cfeffb2037f7060d76c6164a2944b0c Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 27 Apr 2026 10:27:57 +0300 Subject: [PATCH 1/4] fix: throttle repeat actions --- src/common/Shortcuts/Shortcuts.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/Shortcuts/Shortcuts.tsx b/src/common/Shortcuts/Shortcuts.tsx index c9198a857..96b8ffba3 100644 --- a/src/common/Shortcuts/Shortcuts.tsx +++ b/src/common/Shortcuts/Shortcuts.tsx @@ -19,10 +19,20 @@ type Props = { onShortcut: (name: ShortcutName) => void, }; +const REPEAT_THROTTLE_MS = 200; + const ShortcutsProvider = ({ children, onShortcut }: Props) => { const listeners = useRef>>(new Map()); + const lastRepeatTime = useRef>(new Map()); + + const onKeyDown = useCallback(({ ctrlKey, shiftKey, code, key, repeat }: KeyboardEvent) => { + if (repeat) { + const now = Date.now(); + const last = lastRepeatTime.current.get(code) ?? 0; + if (now - last < REPEAT_THROTTLE_MS) return; + lastRepeatTime.current.set(code, now); + } - const onKeyDown = useCallback(({ ctrlKey, shiftKey, code, key }: KeyboardEvent) => { SHORTCUTS.forEach(({ name, combos }) => combos.forEach((keys) => { const modifers = (keys.includes('Ctrl') ? ctrlKey : true) && (keys.includes('Shift') ? shiftKey : true); From 136b3b24d21a737a70af7941122c8697d913c96e Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 27 Apr 2026 10:36:26 +0300 Subject: [PATCH 2/4] Update Shortcuts.tsx --- src/common/Shortcuts/Shortcuts.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/common/Shortcuts/Shortcuts.tsx b/src/common/Shortcuts/Shortcuts.tsx index 96b8ffba3..c9198a857 100644 --- a/src/common/Shortcuts/Shortcuts.tsx +++ b/src/common/Shortcuts/Shortcuts.tsx @@ -19,20 +19,10 @@ type Props = { onShortcut: (name: ShortcutName) => void, }; -const REPEAT_THROTTLE_MS = 200; - const ShortcutsProvider = ({ children, onShortcut }: Props) => { const listeners = useRef>>(new Map()); - const lastRepeatTime = useRef>(new Map()); - - const onKeyDown = useCallback(({ ctrlKey, shiftKey, code, key, repeat }: KeyboardEvent) => { - if (repeat) { - const now = Date.now(); - const last = lastRepeatTime.current.get(code) ?? 0; - if (now - last < REPEAT_THROTTLE_MS) return; - lastRepeatTime.current.set(code, now); - } + const onKeyDown = useCallback(({ ctrlKey, shiftKey, code, key }: KeyboardEvent) => { SHORTCUTS.forEach(({ name, combos }) => combos.forEach((keys) => { const modifers = (keys.includes('Ctrl') ? ctrlKey : true) && (keys.includes('Shift') ? shiftKey : true); From 5f6ff99cb677019c4ef51cbda30e03aeee16e10c Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 27 Apr 2026 11:20:03 +0300 Subject: [PATCH 3/4] Revert "Update Shortcuts.tsx" This reverts commit 136b3b24d21a737a70af7941122c8697d913c96e. --- src/common/Shortcuts/Shortcuts.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/common/Shortcuts/Shortcuts.tsx b/src/common/Shortcuts/Shortcuts.tsx index c9198a857..96b8ffba3 100644 --- a/src/common/Shortcuts/Shortcuts.tsx +++ b/src/common/Shortcuts/Shortcuts.tsx @@ -19,10 +19,20 @@ type Props = { onShortcut: (name: ShortcutName) => void, }; +const REPEAT_THROTTLE_MS = 200; + const ShortcutsProvider = ({ children, onShortcut }: Props) => { const listeners = useRef>>(new Map()); + const lastRepeatTime = useRef>(new Map()); + + const onKeyDown = useCallback(({ ctrlKey, shiftKey, code, key, repeat }: KeyboardEvent) => { + if (repeat) { + const now = Date.now(); + const last = lastRepeatTime.current.get(code) ?? 0; + if (now - last < REPEAT_THROTTLE_MS) return; + lastRepeatTime.current.set(code, now); + } - const onKeyDown = useCallback(({ ctrlKey, shiftKey, code, key }: KeyboardEvent) => { SHORTCUTS.forEach(({ name, combos }) => combos.forEach((keys) => { const modifers = (keys.includes('Ctrl') ? ctrlKey : true) && (keys.includes('Shift') ? shiftKey : true); From 273044444577cdabe3c948fe3cef73bc100ab903 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Mon, 27 Apr 2026 11:20:42 +0300 Subject: [PATCH 4/4] correct throttle ms --- src/common/Shortcuts/Shortcuts.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/Shortcuts/Shortcuts.tsx b/src/common/Shortcuts/Shortcuts.tsx index 96b8ffba3..348471484 100644 --- a/src/common/Shortcuts/Shortcuts.tsx +++ b/src/common/Shortcuts/Shortcuts.tsx @@ -19,7 +19,7 @@ type Props = { onShortcut: (name: ShortcutName) => void, }; -const REPEAT_THROTTLE_MS = 200; +const REPEAT_THROTTLE_MS = 130; const ShortcutsProvider = ({ children, onShortcut }: Props) => { const listeners = useRef>>(new Map());