diff --git a/components/search.tsx b/components/search.tsx index 1557f875..e21ad5ea 100644 --- a/components/search.tsx +++ b/components/search.tsx @@ -9,14 +9,26 @@ import { toast } from "@/components/ui/use-toast" interface DocsSearchProps extends React.HTMLAttributes {} export function DocsSearch({ className, ...props }: DocsSearchProps) { + const inputRef=React.useRef(null) function onSubmit(event: React.SyntheticEvent) { event.preventDefault() - return toast({ title: "Not implemented", description: "We're still working on the search.", }) } + const keyDownHandler = (event: KeyboardEvent) => { + if (event.key === "k" && event.ctrlKey) { + event.preventDefault(); + if (inputRef.current) { + inputRef.current.focus?.(); + } + } + }; + + React.useEffect(() => { + window.addEventListener("keydown", keyDownHandler); + }); return (
K