Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added slash as additional trigger for search #2418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion guide/src/guide/reading.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Tapping the menu bar will scroll the page to the top.
## Search

Each book has a built-in search system.
Pressing the search icon (<i class="fa fa-search"></i>) in the menu bar, or pressing the `S` key on the keyboard will open an input box for entering search terms.
Pressing the search icon (<i class="fa fa-search"></i>) in the menu bar, or pressing the `S` or `/` key on the keyboard will open an input box for entering search terms.
Typing some terms will show matching chapters and sections in real time.

Clicking any of the results will jump to that section.
Expand Down
5 changes: 3 additions & 2 deletions src/theme/searcher/searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ window.search = window.search || {};
URL_MARK_PARAM = 'highlight',
teaser_count = 0,

SEARCH_HOTKEY_KEYCODE = 83,
SEARCH_HOTKEY_KEYCODE_S = 83,
SEARCH_HOTKEY_KEYCODE_SLASH = 191,
ESCAPE_KEYCODE = 27,
DOWN_KEYCODE = 40,
UP_KEYCODE = 38,
Expand Down Expand Up @@ -328,7 +329,7 @@ window.search = window.search || {};
}
showSearch(false);
marker.unmark();
} else if (!hasFocus() && e.keyCode === SEARCH_HOTKEY_KEYCODE) {
} else if (!hasFocus() && (e.keyCode === SEARCH_HOTKEY_KEYCODE_S) || (e.keyCode === SEARCH_HOTKEY_KEYCODE_SLASH)) {
e.preventDefault();
showSearch(true);
window.scrollTo(0, 0);
Expand Down