diff --git a/src/discord/globalKeybinds.ts b/src/discord/globalKeybinds.ts index 297281df..40d6e765 100644 --- a/src/discord/globalKeybinds.ts +++ b/src/discord/globalKeybinds.ts @@ -8,9 +8,11 @@ export function registerGlobalKeybinds() { const keybinds = getConfig("keybinds"); keybinds.forEach((keybind: Keybind) => { if (keybind.enabled && keybind.global) { - globalShortcut.register(keybind.accelerator, () => { - runAction(keybind); - }); + try { + globalShortcut.register(keybind.accelerator, () => { + runAction(keybind); + }); + } catch {} } }); } diff --git a/src/shelter/settings/components/KeybindMaker.tsx b/src/shelter/settings/components/KeybindMaker.tsx index d541cbb6..b8a8e8bb 100644 --- a/src/shelter/settings/components/KeybindMaker.tsx +++ b/src/shelter/settings/components/KeybindMaker.tsx @@ -33,6 +33,7 @@ export const KeybindMaker = (props: { close: () => void }) => { let logged: string[] = []; let containsNonModifier = false; + let containsNumpadKey = false; let timeout: NodeJS.Timeout | null = null; function log(event: KeyboardEvent) { const key = event.key.replace(" ", "Space"); @@ -41,7 +42,11 @@ export const KeybindMaker = (props: { close: () => void }) => { } else { console.log(key); logged.unshift(key); - if (event.location === 0) containsNonModifier = true; + if (event.location === 0) { + containsNonModifier = true; + } else if (event.location === 3) { + containsNumpadKey = true; + } setAccelerator(logged.join("+")); } if (timeout) clearTimeout(timeout); @@ -66,6 +71,7 @@ export const KeybindMaker = (props: { close: () => void }) => { logged = []; containsNonModifier = false; + containsNumpadKey = false; setAccelerator(""); console.log("Recording start"); document.body.addEventListener("keyup", log); @@ -93,8 +99,8 @@ export const KeybindMaker = (props: { close: () => void }) => {
Accelerator
- -

Modifier-only shortcuts are not supported.

+ +

This key combination is invalid or not supported.

@@ -152,7 +158,7 @@ export const KeybindMaker = (props: { close: () => void }) => { confirmText="Add" onConfirm={save} close={props.close} - disabled={recording() || !accelerator() || !containsNonModifier} + disabled={recording() || !accelerator() || !containsNonModifier || containsNumpadKey} /> );