feat: Change global search shortcut from Cmd+K to Ctrl+Shift+F
This commit is contained in:
parent
44f2fbd4d6
commit
11f7ca4fbf
2 changed files with 5 additions and 5 deletions
|
|
@ -67,7 +67,7 @@ export default function App() {
|
||||||
<SearchAutocomplete
|
<SearchAutocomplete
|
||||||
variant="nav"
|
variant="nav"
|
||||||
globalShortcut
|
globalShortcut
|
||||||
placeholder="Search… ⌘K"
|
placeholder="Search… Ctrl+⇧F"
|
||||||
onSearch={(q) => navigate(`/search?q=${encodeURIComponent(q)}`)}
|
onSearch={(q) => navigate(`/search?q=${encodeURIComponent(q)}`)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ interface SearchAutocompleteProps {
|
||||||
variant?: 'hero' | 'inline' | 'nav';
|
variant?: 'hero' | 'inline' | 'nav';
|
||||||
initialQuery?: string;
|
initialQuery?: string;
|
||||||
autoFocus?: boolean;
|
autoFocus?: boolean;
|
||||||
/** When true, Cmd+K / Ctrl+K focuses the input globally */
|
/** When true, Ctrl+Shift+F focuses the input globally */
|
||||||
globalShortcut?: boolean;
|
globalShortcut?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,11 +72,11 @@ export default function SearchAutocomplete({
|
||||||
if (autoFocus) inputRef.current?.focus();
|
if (autoFocus) inputRef.current?.focus();
|
||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
// Global Cmd+K / Ctrl+K shortcut to focus input
|
// Global Ctrl+Shift+F shortcut to focus input
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!globalShortcut) return;
|
if (!globalShortcut) return;
|
||||||
function handleGlobalKey(e: KeyboardEvent) {
|
function handleGlobalKey(e: KeyboardEvent) {
|
||||||
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
|
if (e.key === "F" && e.ctrlKey && e.shiftKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
inputRef.current?.focus();
|
inputRef.current?.focus();
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +188,7 @@ export default function SearchAutocomplete({
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{variant === 'nav' && (
|
{variant === 'nav' && (
|
||||||
<kbd className="search-nav__shortcut">⌘K</kbd>
|
<kbd className="search-nav__shortcut">Ctrl⇧F</kbd>
|
||||||
)}
|
)}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue