diff --git a/src/lib/components/SearchField.svelte b/src/lib/components/SearchField.svelte index 2ce392a..70127aa 100644 --- a/src/lib/components/SearchField.svelte +++ b/src/lib/components/SearchField.svelte @@ -94,7 +94,7 @@ type="text" id="search" name="query" - placeholder={`Search method ${$isMacDevice ? '(CMD + K)' : '(CTRL + M)'}`} + placeholder="Search method (/)" on:keyup={(e) => { updateSearchQuery(e); }} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 032c66a..d34d102 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -3,12 +3,7 @@ import Topbar from '$lib/components/layout/Topbar.svelte'; import Sidebar from '$lib/components/layout/sidebar/Sidebar.svelte'; - import { - showSearchField, - allMethods, - isJavaScriptDisabled, - isMacDevice - } from '$lib/stores'; + import { showSearchField, allMethods, isJavaScriptDisabled, isMacDevice } from '$lib/stores'; import { onMount } from 'svelte'; import { getTheme } from '$lib/utils/themeManager'; @@ -57,14 +52,16 @@ const isKClicked = event.key === 'k'; const isMClicked = event.key === 'm'; const isEscClicked = event.key === 'Escape'; + const isSlashClicked = event.key === '/'; const cmdKWindows = isCtrlClicked && isMClicked; // CTRL + K is existing shortcut in Chrome const cmdKMac = isCommandClicked && isKClicked; const searchField = document.getElementById('search'); - if (cmdKWindows || cmdKMac) { + if (cmdKWindows || cmdKMac || isSlashClicked) { searchField?.focus(); + event.preventDefault(); } if (isEscClicked) {