Skip to content

Commit

Permalink
accept cmd+k for search
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed Aug 10, 2022
1 parent 6fc7160 commit ce2abb9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion docs/assets/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,12 @@

// Show the search panel slash is pressed outside of a form element
document.addEventListener('keydown', event => {
const isSlash = event.key === '/';
const isCtrlK = (event.metaKey || event.ctrlKey) && event.key === 'k';

if (
!isShowing &&
event.key === '/' &&
(isSlash || isCtrlK) &&
!event.composedPath().some(el => ['input', 'textarea'].includes(el?.tagName?.toLowerCase()))
) {
event.preventDefault();
Expand Down

0 comments on commit ce2abb9

Please sign in to comment.