Skip to content

Commit 0e25e9a

Browse files
committed
Added slash as additional trigger for search
1 parent b7a27d2 commit 0e25e9a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-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/front-end/searcher/searcher.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ window.search = window.search || {};
3434
URL_SEARCH_PARAM = 'search',
3535
URL_MARK_PARAM = 'highlight',
3636

37-
SEARCH_HOTKEY_KEYCODE = 83,
37+
SEARCH_HOTKEY_KEYCODE_S = 83,
38+
SEARCH_HOTKEY_KEYCODE_SLASH = 191,
3839
ESCAPE_KEYCODE = 27,
3940
DOWN_KEYCODE = 40,
4041
UP_KEYCODE = 38,
@@ -358,7 +359,8 @@ window.search = window.search || {};
358359
}
359360
showSearch(false);
360361
marker.unmark();
361-
} else if (!hasFocus() && e.keyCode === SEARCH_HOTKEY_KEYCODE) {
362+
} else if (!hasFocus() && (e.keyCode === SEARCH_HOTKEY_KEYCODE_S
363+
|| e.keyCode === SEARCH_HOTKEY_KEYCODE_SLASH)) {
362364
e.preventDefault();
363365
showSearch(true);
364366
window.scrollTo(0, 0);

0 commit comments

Comments
 (0)