diff --git a/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx b/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx index 0a8afbf..d93c05b 100644 --- a/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx +++ b/crates/lanspread-tauri-deno-ts/src/components/topbar/SearchField.tsx @@ -26,6 +26,8 @@ export const SearchField = ({ value, onChange }: Props) => { return () => window.removeEventListener('keydown', onKey); }, []); + const blurInput = () => inputRef.current?.blur(); + return (
@@ -35,6 +37,16 @@ export const SearchField = ({ value, onChange }: Props) => { placeholder="Search games" value={value} onChange={(e) => onChange(e.target.value)} + onKeyDown={(e) => { + if (e.key === 'Enter') { + e.preventDefault(); + blurInput(); + } else if (e.key === 'Escape') { + e.preventDefault(); + onChange(''); + blurInput(); + } + }} spellCheck={false} /> /