diff --git a/src/lib/components/SearchBox.svelte b/src/lib/components/SearchBox.svelte index cdcd24e..9920f15 100644 --- a/src/lib/components/SearchBox.svelte +++ b/src/lib/components/SearchBox.svelte @@ -8,6 +8,7 @@ let open = $state(false); let searching = $state(false); let activeIndex = $state(-1); + let inputEl = $state(null); let timer: ReturnType | null = null; let seq = 0; @@ -88,15 +89,46 @@ if (query.trim().length >= 2) open = true; } + // Global "/" shortcut, unless the user is typing somewhere else + function onWindowKeydown(e: KeyboardEvent) { + if (e.key !== "/" || e.metaKey || e.ctrlKey || e.altKey) return; + const t = e.target as HTMLElement | null; + if ( + t && + (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) + ) + return; + e.preventDefault(); + inputEl?.focus(); + } + function onBlur() { // Delay so a mousedown on a result still lands setTimeout(() => close(), 120); } + +
+ -
{#if open}