chore(repo): prune dead code and duplicate abstractions (#3413)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-12 13:09:42 +02:00
1 parent c17091768c
commit c9fdf8fead
2937 files changed
+42233 -176793

No files matched your search

@@ -0,0 +1,46 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
export const PUNCTUATION_KEY_CODES: Readonly<Record<string, string>> = {
' ': 'Space',
'-': 'Minus',
_: 'Minus',
'=': 'Equal',
'+': 'Equal',
',': 'Comma',
'<': 'Comma',
'.': 'Period',
'>': 'Period',
';': 'Semicolon',
':': 'Semicolon',
"'": 'Quote',
'"': 'Quote',
'/': 'Slash',
'?': 'Slash',
'\\': 'Backslash',
'|': 'Backslash',
'[': 'BracketLeft',
'{': 'BracketLeft',
']': 'BracketRight',
'}': 'BracketRight',
'`': 'Backquote',
'~': 'Backquote',
};
export function isPrintableShortcutKey(key: string | null | undefined): key is string {
if (!key) return false;
if (key === 'Dead' || key === 'Unidentified' || key === 'Process') return false;
return key.length === 1;
}
export function shouldPreferLayoutKey(combo: {key?: string | null; code?: string}): boolean {
if (!isPrintableShortcutKey(combo.key)) return false;
return !(combo.code && /^Numpad/.test(combo.code));
}
export function hookKeyNameForLayoutKey(key: string): string | null {
if (key.length !== 1) return null;
const punctuation = PUNCTUATION_KEY_CODES[key];
if (punctuation) return punctuation;
const upper = key.toUpperCase();
return /^[A-Z0-9]$/.test(upper) ? upper : null;
}