Skip to content
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
10 changes: 10 additions & 0 deletions crates/mdbook-html/front-end/searcher/searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,16 @@ window.search = window.search || {};

// Eventhandler for keyevents on `document`
function globalKeyHandler(e) {
const metaIsCtrl = navigator.platform &&
(navigator.platform.startsWith('Mac') || navigator.platform === 'iPhone');
if ((metaIsCtrl ? e.metaKey : e.ctrlKey) && e.key === 'k') {
e.preventDefault();
showSearch(true);
window.scrollTo(0, 0);
searchbar.select();
return;
}

if (e.altKey ||
e.ctrlKey ||
e.metaKey ||
Expand Down
7 changes: 6 additions & 1 deletion crates/mdbook-html/front-end/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@
<div>
<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>
{{#if search_enabled}}
<p>Press <kbd>S</kbd> or <kbd>/</kbd> to search in the book</p>
<p>Press <kbd>S</kbd>, <kbd>/</kbd>, or <kbd id="kbd-ctrl-cmd">Ctrl</kbd>+<kbd>K</kbd> to search in the book</p>
<script>
if (navigator.platform && (navigator.platform.startsWith("Mac") || navigator.platform === "iPhone")) {
document.getElementById("kbd-ctrl-cmd").innerText = "⌘";
}
</script>
{{/if}}
<p>Press <kbd>?</kbd> to show this help</p>
<p>Press <kbd>Esc</kbd> to hide this help</p>
Expand Down
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="fas fa-magnifying-glass"></i> in the menu bar, or pressing the <kbd>/</kbd> or <kbd>S</kbd> key on the keyboard will open an input box for entering search terms.
Pressing the search icon <i class="fas fa-magnifying-glass"></i> in the menu bar, <kbd>Ctrl</kbd>+<kbd>K</kbd> (<kbd>⌘</kbd>+<kbd>K</kbd> on macOS), or pressing the <kbd>/</kbd> or <kbd>S</kbd> 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