[Glitch] refactor: Replace react-hotkeys with custom hook

Port 4de5cbd6f5 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion
2025-07-21 16:43:38 +02:00
committed by Claire
parent 105315a2e3
commit 0ae7c7e406
12 changed files with 361 additions and 91 deletions

View File

@@ -0,0 +1,29 @@
export function isKeyboardEvent(event: Event): event is KeyboardEvent {
return 'key' in event;
}
export function normalizeKey(key: string): string {
const lowerKey = key.toLowerCase();
switch (lowerKey) {
case ' ':
case 'spacebar': // for older browsers
return 'space';
case 'arrowup':
return 'up';
case 'arrowdown':
return 'down';
case 'arrowleft':
return 'left';
case 'arrowright':
return 'right';
case 'esc':
case 'escape':
return 'escape';
default:
return lowerKey;
}
}