mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-18 01:14:22 +02:00
fix: punctuation hotkeys not captured (#2091)
This commit is contained in:
@@ -2,6 +2,20 @@ import type { HotkeyItem } from '@mantine/hooks';
|
|||||||
|
|
||||||
const RESERVED_KEYS = new Set(['alt', 'ctrl', 'meta', 'mod', 'shift']);
|
const RESERVED_KEYS = new Set(['alt', 'ctrl', 'meta', 'mod', 'shift']);
|
||||||
|
|
||||||
|
const PUNCTUATION_KEY_TO_PHYSICAL: Record<string, string> = {
|
||||||
|
"'": 'Quote',
|
||||||
|
',': 'Comma',
|
||||||
|
'-': 'Minus',
|
||||||
|
'.': 'Period',
|
||||||
|
'/': 'Slash',
|
||||||
|
';': 'Semicolon',
|
||||||
|
'=': 'Equal',
|
||||||
|
'[': 'BracketLeft',
|
||||||
|
'\\': 'Backslash',
|
||||||
|
']': 'BracketRight',
|
||||||
|
'`': 'Backquote',
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts stored hotkey strings to Mantine's physical-key format.
|
* Converts stored hotkey strings to Mantine's physical-key format.
|
||||||
* Mantine matches KeyboardEvent.code via normalizeKey, which turns Digit1 into
|
* Mantine matches KeyboardEvent.code via normalizeKey, which turns Digit1 into
|
||||||
@@ -25,6 +39,11 @@ export const toPhysicalHotkey = (hotkey: string): string =>
|
|||||||
return `Digit${part}`;
|
return `Digit${part}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const punctuationPhysical = PUNCTUATION_KEY_TO_PHYSICAL[part];
|
||||||
|
if (punctuationPhysical) {
|
||||||
|
return punctuationPhysical;
|
||||||
|
}
|
||||||
|
|
||||||
return part;
|
return part;
|
||||||
})
|
})
|
||||||
.join('+');
|
.join('+');
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ const CODE_TO_HOTKEY_KEY: Record<string, string> = {
|
|||||||
ArrowLeft: 'arrowleft',
|
ArrowLeft: 'arrowleft',
|
||||||
ArrowRight: 'arrowright',
|
ArrowRight: 'arrowright',
|
||||||
ArrowUp: 'arrowup',
|
ArrowUp: 'arrowup',
|
||||||
|
Backquote: '`',
|
||||||
|
Backslash: '\\',
|
||||||
Backspace: 'backspace',
|
Backspace: 'backspace',
|
||||||
|
BracketLeft: '[',
|
||||||
|
BracketRight: ']',
|
||||||
|
Comma: ',',
|
||||||
Delete: 'delete',
|
Delete: 'delete',
|
||||||
End: 'end',
|
End: 'end',
|
||||||
Enter: 'enter',
|
Enter: 'enter',
|
||||||
@@ -14,6 +19,10 @@ const CODE_TO_HOTKEY_KEY: Record<string, string> = {
|
|||||||
Minus: 'minus',
|
Minus: 'minus',
|
||||||
PageDown: 'pagedown',
|
PageDown: 'pagedown',
|
||||||
PageUp: 'pageup',
|
PageUp: 'pageup',
|
||||||
|
Period: '.',
|
||||||
|
Quote: "'",
|
||||||
|
Semicolon: ';',
|
||||||
|
Slash: '/',
|
||||||
Space: 'space',
|
Space: 'space',
|
||||||
Tab: 'tab',
|
Tab: 'tab',
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user