diff options
author | 2022-12-21 00:21:12 +0100 | |
---|---|---|
committer | 2022-12-21 00:21:12 +0100 | |
commit | bf88836dbe4037019e9545deaae1db06e5768cfb (patch) | |
tree | b33977da939d5db0507cebb3be7103277e2a06c3 /src | |
parent | bfc2e24bbfc08f67ed9c9b1d93474029bc01dc8b (diff) | |
download | it-tools-bf88836dbe4037019e9545deaae1db06e5768cfb.tar.gz it-tools-bf88836dbe4037019e9545deaae1db06e5768cfb.tar.zst it-tools-bf88836dbe4037019e9545deaae1db06e5768cfb.zip |
feat(search-bar): use cmd + k to focus on mac
Diffstat (limited to 'src')
-rw-r--r-- | src/components/SearchBar.vue | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/components/SearchBar.vue b/src/components/SearchBar.vue index a93f46a..dd63506 100644 --- a/src/components/SearchBar.vue +++ b/src/components/SearchBar.vue @@ -40,16 +40,25 @@ const keys = useMagicKeys({ if (e.ctrlKey && e.key === 'k' && e.type === 'keydown') { e.preventDefault(); } + + if (e.metaKey && e.key === 'k' && e.type === 'keydown') { + e.preventDefault(); + } }, }); whenever(keys.ctrl_k, () => { focusTarget.value.focus(); }); +whenever(keys.meta_k, () => { + focusTarget.value.focus(); +}); function renderOption({ tool }: { tool: Tool }) { return h(SearchBarItem, { tool }); } + +const isMac = computed(() => window.navigator.userAgent.toLowerCase().includes('mac')); </script> <template> @@ -68,7 +77,7 @@ function renderOption({ tool }: { tool: Tool }) { ref="focusTarget" round clearable - placeholder="Search a tool... [Ctrl + K]" + :placeholder="`Search a tool (use ${isMac ? 'Cmd' : 'Ctrl'} + K to focus)`" :value="slotValue" :input-props="{ autocomplete: 'disabled' }" @input="handleInput" |