feat(docsearch): add / keyboard shortcut
This commit is contained in:
parent
c13fa9f7bb
commit
5725023ae7
1 changed files with 5 additions and 1 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue