search v1
This commit is contained in:
17
app/plugins/search-shortcut.client.ts
Normal file
17
app/plugins/search-shortcut.client.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useUiStore } from '~/store/ui'
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
const ui = useUiStore()
|
||||
const isMobile = nuxtApp.$isMobile as boolean | undefined
|
||||
|
||||
const onKeyDown = (e: KeyboardEvent) => {
|
||||
if ((e.metaKey || e.ctrlKey) && (e.key === 'f' || e.key === 'F')) {
|
||||
if (isMobile) return
|
||||
e.preventDefault()
|
||||
if (!ui.showSearch) ui.openSearch()
|
||||
}
|
||||
}
|
||||
|
||||
if (process.client) {
|
||||
window.addEventListener('keydown', onKeyDown)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user