feat(web): add ? cheatsheet and / focus-search hotkeys
- New ShortcutsHelp modal enumerates global, nav G-chord and palette bindings; openable via ? (Shift+/) or the command palette. - / dispatches a global decnet:focus-search event; Attackers, Bounty and LiveLogs listen and focus their in-page search inputs (pages without a local search are skipped per plan). - Respects the existing editable-element guard and Alt+K palette toggle; no rebinds to prior shortcuts.
This commit is contained in:
18
decnet_web/src/hooks/useFocusSearch.ts
Normal file
18
decnet_web/src/hooks/useFocusSearch.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useEffect, RefObject } from 'react';
|
||||
|
||||
/**
|
||||
* Focus the given input when the global `decnet:focus-search` event fires
|
||||
* (dispatched by the `/` hotkey in useGlobalHotkeys).
|
||||
*/
|
||||
export function useFocusSearch(ref: RefObject<HTMLInputElement | null>): void {
|
||||
useEffect(() => {
|
||||
const handler = () => {
|
||||
const el = ref.current;
|
||||
if (!el) return;
|
||||
el.focus();
|
||||
try { el.select(); } catch { /* ignore */ }
|
||||
};
|
||||
window.addEventListener('decnet:focus-search', handler);
|
||||
return () => window.removeEventListener('decnet:focus-search', handler);
|
||||
}, [ref]);
|
||||
}
|
||||
Reference in New Issue
Block a user