diff --git a/src/useDocSearchKeyboardEvents.ts b/src/useDocSearchKeyboardEvents.ts index f869ba8a4..61c387724 100644 --- a/src/useDocSearchKeyboardEvents.ts +++ b/src/useDocSearchKeyboardEvents.ts @@ -5,7 +5,11 @@ export function useDocSearchKeyboardEvents({ isOpen, onOpen, onClose }) { function onKeyDown(event: KeyboardEvent) { if ( (event.keyCode === 27 && isOpen) || - (event.key === 'k' && (event.metaKey || event.ctrlKey)) + // The `Cmd+K` shortcut both opens and closes the modal. + (event.key === 'k' && (event.metaKey || event.ctrlKey)) || + // The `/` shortcut opens but doesn't close the modal because it's + // a character. + (event.key === '/' && !isOpen) ) { event.preventDefault();