fix(client): delete shortcut key not working

This commit is contained in:
Elian Doran
2025-10-03 15:39:13 +03:00
parent 9a2440942b
commit b450a4faa0
2 changed files with 18 additions and 4 deletions

View File

@@ -36,10 +36,18 @@ const keyMap: { [key: string]: string[] } = {
};
// Function keys
const functionKeyCodes: string[] = [];
for (let i = 1; i <= 19; i++) {
keyMap[`f${i}`] = [`F${i}`];
const keyCode = `F${i}`;
functionKeyCodes.push(keyCode);
keyMap[`f${i}`] = [ keyCode ];
}
const KEYCODES_WITH_NO_MODIFIER = new Set([
"Delete",
...functionKeyCodes
]);
/**
* Check if IME (Input Method Editor) is composing
* This is used to prevent keyboard shortcuts from firing during IME composition
@@ -163,8 +171,8 @@ export function matchesShortcut(e: KeyboardEvent, shortcut: string): boolean {
const expectedMeta = modifiers.includes('meta') || modifiers.includes('cmd') || modifiers.includes('command');
// Refuse key combinations that don't include modifiers because they interfere with the normal usage of the application.
// Function keys are an exception.
if (!(expectedCtrl || expectedAlt || expectedShift || expectedMeta) && !/f\d+/.test(key)) {
// Some keys such as function keys are an exception.
if (!(expectedCtrl || expectedAlt || expectedShift || expectedMeta) && !KEYCODES_WITH_NO_MODIFIER.has(e.code)) {
return false;
}