Skip to content

Commit 586af99

Browse files
committed
Added slash as additional trigger for search
1 parent ec996d3 commit 586af99

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

guide/src/guide/reading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Tapping the menu bar will scroll the page to the top.
4242
## Search
4343

4444
Each book has a built-in search system.
45-
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.
45+
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.
4646
Typing some terms will show matching chapters and sections in real time.
4747

4848
Clicking any of the results will jump to that section.

src/theme/searcher/searcher.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ window.search = window.search || {};
4848
URL_MARK_PARAM = 'highlight',
4949
teaser_count = 0,
5050

51-
SEARCH_HOTKEY_KEYCODE = 83,
51+
SEARCH_HOTKEY_KEYCODE_S = 83,
52+
SEARCH_HOTKEY_KEYCODE_SLASH = 191,
5253
ESCAPE_KEYCODE = 27,
5354
DOWN_KEYCODE = 40,
5455
UP_KEYCODE = 38,
@@ -328,7 +329,7 @@ window.search = window.search || {};
328329
}
329330
showSearch(false);
330331
marker.unmark();
331-
} else if (!hasFocus() && e.keyCode === SEARCH_HOTKEY_KEYCODE) {
332+
} else if (!hasFocus() && (e.keyCode === SEARCH_HOTKEY_KEYCODE_S) || (e.keyCode === SEARCH_HOTKEY_KEYCODE_SLASH)) {
332333
e.preventDefault();
333334
showSearch(true);
334335
window.scrollTo(0, 0);

0 commit comments

Comments
 (0)