Skip to content

Commit

Permalink
fix(plugin-docsearch): allow using slash key to init docsearch (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusteixeiradias committed May 8, 2023
1 parent d91996f commit 3382bb1
Showing 1 changed file with 9 additions and 4 deletions.
Expand Up @@ -5,10 +5,15 @@ import { useEventListener } from '@vueuse/core'
*/
export const useDocsearchHotkeyListener = (callback: () => void): void => {
const remove = useEventListener('keydown', (event) => {
if (event.key === 'k' && (event.ctrlKey || event.metaKey)) {
event.preventDefault()
callback()
remove()
const isHotKeyBind = event.key === 'k' && (event.ctrlKey || event.metaKey)
const isSlashKey = event.key === '/'

if (!isSlashKey && !isHotKeyBind) {
return
}

event.preventDefault()
callback()
remove()
})
}

0 comments on commit 3382bb1

Please sign in to comment.