feat: add keyboard shortcut to focus header search bar

This commit is contained in:
cj-do-gta-sander 2024-10-24 12:11:49 -03:00
parent 2a6346cb69
commit 3adc8662dc

View File

@ -65,6 +65,19 @@ export function Header({ onSearch, onClear, search }: HeaderProps) {
navigate(-1); navigate(-1);
}; };
useEffect(() => {
window.onkeydown = (event: KeyboardEvent) => {
const { key, ctrlKey } = event;
if (!isFocused && ctrlKey && key === "k") {
focusInput();
}
};
return () => {
window.onkeydown = null;
};
}, [isFocused]);
return ( return (
<> <>
<header <header