Skip to content

Commit

Permalink
Merge pull request #232 from HBO-i/feature/replace-cmd-k-with-slash
Browse files Browse the repository at this point in the history
Add slash besides command K for search method
  • Loading branch information
jochemvogel authored Apr 28, 2024
2 parents 9e20c6b + bb60c42 commit 36c041a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/SearchField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}}
Expand Down
11 changes: 4 additions & 7 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 36c041a

Please sign in to comment.