Add cmd-k/ctrl-k shortcut to focus searchbar #1870
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello ex_doc team!
This PR adds
cmd-k
(Mac) andctrl-k
(Win, Linux) to focus the search input.This is the first of two features I agreed to take on discussed in #1860. The second part is prevent the entire page from scrolling to the top when focusing the search bar and instead making it slide down over the content. I'm happy to roll that into this PR but I wanted to get a review on this now since I don't have easy access to Windows of Linux machines so I would appreciate if someone could test the
ctrl-k
version.I tried to stay very low-ceremony with this PR doing the simplest thing I could think of. I've added a simple
hasModifier
option for shortcuts which will require that the system-appropriate shortcut key be used. While of course/
still works, I've made the placeholder hint show theK
versions instead since I feel that is far more common these days. Because it's system dependent, this had to be done with JavaScript.Thanks, and the resolution to #1860 is coming soon!