live hotkey capture

This commit is contained in:
2026-05-12 00:08:24 +03:00
parent 14d02cdad4
commit 7a821f54fc
3 changed files with 144 additions and 45 deletions
+13 -25
View File
@@ -1,20 +1,21 @@
<script lang="ts">
import { api } from "./api"
import HotkeyInput from "./HotkeyInput.svelte"
let { onDone }: { onDone: () => void } = $props()
let start = $state("")
let stop = $state("")
let pause = $state("")
let saving = $state(false)
let start: string | null = $state(null)
let stop: string | null = $state(null)
let pause: string | null = $state(null)
let saving: boolean = $state(false)
async function save() {
saving = true
try {
const cfg = await api.getConfig()
cfg.hotkeys.start = start.trim() || null
cfg.hotkeys.stop = stop.trim() || null
cfg.hotkeys.pause = pause.trim() || null
cfg.hotkeys.start = start
cfg.hotkeys.stop = stop
cfg.hotkeys.pause = pause
await api.saveConfig(cfg)
onDone()
} finally {
@@ -22,7 +23,7 @@
}
}
let valid = $derived(start.trim() && stop.trim() && pause.trim())
let valid = $derived(!!start && !!stop && !!pause)
</script>
<main>
@@ -37,15 +38,15 @@
<div class="form">
<label>
<span>start</span>
<input bind:value={start} placeholder="e.g. F9" />
<HotkeyInput bind:value={start} placeholder="e.g. F9" />
</label>
<label>
<span>stop</span>
<input bind:value={stop} placeholder="e.g. F9" />
<HotkeyInput bind:value={stop} placeholder="e.g. F9" />
</label>
<label>
<span>pause</span>
<input bind:value={pause} placeholder="e.g. F10" />
<HotkeyInput bind:value={pause} placeholder="e.g. F10" />
</label>
</div>
<div class="row">
@@ -54,8 +55,7 @@
</button>
</div>
<p class="hint">
Live key capture isn't wired up yet - for now type the combination as text
(F9, Ctrl+Shift+R, etc).
Click each field, then press your combo. Escape cancels.
</p>
</main>
@@ -90,18 +90,6 @@
color: #aaa;
font-size: 0.875rem;
}
input {
font: inherit;
padding: 0.45rem 0.6rem;
border: 1px solid #444;
background: #222;
color: inherit;
border-radius: 4px;
}
input:focus {
outline: none;
border-color: #4a8;
}
.row {
display: flex;
gap: 0.5rem;