fix: shortcuts only block keyboard actions when needed, and change some keybinds

This commit is contained in:
Zoe
2026-02-26 10:26:48 -06:00
parent fd6288a927
commit 2c32e665f3
3 changed files with 25 additions and 14 deletions
+3 -5
View File
@@ -1,10 +1,10 @@
export const useKeyboardShortcuts = () => {
const shortcutsMap = new Map<string, () => void>();
const shortcutsMap = new Map<string, (event: KeyboardEvent) => void>();
const normalize = (combo: string[]) =>
combo.map(k => k.toLowerCase()).sort().join('+');
const addShortcut = (combo: string[], callback: () => void) => {
const addShortcut = (combo: string[], callback: (event: KeyboardEvent) => void) => {
const normalizedKey = normalize(combo);
shortcutsMap.set(normalizedKey, callback);
@@ -28,9 +28,7 @@ export const useKeyboardShortcuts = () => {
const pressedCombo = normalize(keys);
if (shortcutsMap.has(pressedCombo)) {
event.preventDefault();
event.stopPropagation();
shortcutsMap.get(pressedCombo)!();
shortcutsMap.get(pressedCombo)!(event);
}
};