Files
evilspins/app/plugins/search-shortcut.client.ts
valere 0aa1a57b78
All checks were successful
Deploy App / build (push) Successful in 1m5s
Deploy App / deploy (push) Successful in 14s
search v1
2025-10-16 01:45:28 +02:00

18 lines
476 B
TypeScript

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)
}
})