18 lines
		
	
	
		
			476 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			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)
 | |
|   }
 | |
| })
 |