diff --git a/src/ui/settings/Keybind.svelte b/src/ui/settings/Keybind.svelte index 676c50a..8e3f3c9 100644 --- a/src/ui/settings/Keybind.svelte +++ b/src/ui/settings/Keybind.svelte @@ -7,6 +7,7 @@ const id = Math.random().toString().slice(2); const dispatch = createEventDispatcher(); + const modifierKeys = new Set(['Alt', 'AltGraph', 'Control', 'Fn', 'FnLock', 'Meta', 'Shift', 'Super', ]); let listening = false; function listen() { @@ -20,12 +21,15 @@ } function setKeybind(event) { - console.log(event); + // separate events fire for modifier keys, even when they are combined with a regular key + if (modifierKeys.has(event.key)) return; + let keys = []; - if (event.ctrlKey) keys.push('ctrl'); - if (event.altKey) keys.push('alt'); - if (event.metaKey) keys.push('meta'); - if (event.shiftKey) keys.push('shift'); + if (event.ctrlKey) keys.push('Ctrl'); + if (event.altKey) keys.push('Alt'); + if (event.metaKey) keys.push('Meta'); + if (event.shiftKey) keys.push('Shift'); + // capitalize keys.push(event.key); value.keys = keys.join('+');