From 0e25e9ade97f6ec11dfc271faaeb1d73a1b4d67d Mon Sep 17 00:00:00 2001 From: rik86189 <75071538+rik86189@users.noreply.github.com> Date: Sun, 18 Aug 2024 14:39:43 +0200 Subject: [PATCH] Added slash as additional trigger for search --- guide/src/guide/reading.md | 2 +- src/front-end/searcher/searcher.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/guide/src/guide/reading.md b/guide/src/guide/reading.md index cab3a86538..9ded51b790 100644 --- a/guide/src/guide/reading.md +++ b/guide/src/guide/reading.md @@ -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 () 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 () 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. diff --git a/src/front-end/searcher/searcher.js b/src/front-end/searcher/searcher.js index 4d18b138c8..3fef26cb39 100644 --- a/src/front-end/searcher/searcher.js +++ b/src/front-end/searcher/searcher.js @@ -34,7 +34,8 @@ window.search = window.search || {}; URL_SEARCH_PARAM = 'search', URL_MARK_PARAM = 'highlight', - SEARCH_HOTKEY_KEYCODE = 83, + SEARCH_HOTKEY_KEYCODE_S = 83, + SEARCH_HOTKEY_KEYCODE_SLASH = 191, ESCAPE_KEYCODE = 27, DOWN_KEYCODE = 40, UP_KEYCODE = 38, @@ -358,7 +359,8 @@ 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);