From b47c7a9cc44d1161b658049b970fcce1c85883c7 Mon Sep 17 00:00:00 2001 From: Callum Tolley Date: Sun, 16 Nov 2025 10:26:46 +0000 Subject: [PATCH 1/4] =?UTF-8?q?Add=20Ctrl+K=20(or=20=E2=8C=98-K=20if=20on?= =?UTF-8?q?=20macOS)=20to=20bring=20up=20the=20search=20bar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/mdbook-html/front-end/searcher/searcher.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/mdbook-html/front-end/searcher/searcher.js b/crates/mdbook-html/front-end/searcher/searcher.js index c715201205..7107bed729 100644 --- a/crates/mdbook-html/front-end/searcher/searcher.js +++ b/crates/mdbook-html/front-end/searcher/searcher.js @@ -351,6 +351,15 @@ 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 || From 74d3d4e78ff50c6d6d03af31afe3876019e04304 Mon Sep 17 00:00:00 2001 From: Callum Tolley Date: Sun, 16 Nov 2025 10:27:03 +0000 Subject: [PATCH 2/4] =?UTF-8?q?Add=20documentation=20for=20Ctrl/=E2=8C=98+?= =?UTF-8?q?K?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/mdbook-html/front-end/templates/index.hbs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/mdbook-html/front-end/templates/index.hbs b/crates/mdbook-html/front-end/templates/index.hbs index b1834189f9..06272d83e5 100644 --- a/crates/mdbook-html/front-end/templates/index.hbs +++ b/crates/mdbook-html/front-end/templates/index.hbs @@ -69,7 +69,12 @@

Press or to navigate between chapters

{{#if search_enabled}} -

Press S or / to search in the book

+

Press S, /, or Ctrl+K to search in the book

+ {{/if}}

Press ? to show this help

Press Esc to hide this help

From ee873ecad337cac722a20779c82d8816b72b5ff8 Mon Sep 17 00:00:00 2001 From: Callum Tolley Date: Sun, 16 Nov 2025 10:34:20 +0000 Subject: [PATCH 3/4] Fix eslint --- crates/mdbook-html/front-end/searcher/searcher.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/mdbook-html/front-end/searcher/searcher.js b/crates/mdbook-html/front-end/searcher/searcher.js index 7107bed729..a2e0488001 100644 --- a/crates/mdbook-html/front-end/searcher/searcher.js +++ b/crates/mdbook-html/front-end/searcher/searcher.js @@ -351,7 +351,8 @@ window.search = window.search || {}; // Eventhandler for keyevents on `document` function globalKeyHandler(e) { - const metaIsCtrl = navigator.platform && (navigator.platform.startsWith("Mac") || navigator.platform === "iPhone"); + const metaIsCtrl = navigator.platform && + (navigator.platform.startsWith('Mac') || navigator.platform === 'iPhone'); if ((metaIsCtrl ? e.metaKey : e.ctrlKey) && e.key === 'k') { e.preventDefault(); showSearch(true); From f230d938934ff1ebd0c8df2fcb75fec0b713d88c Mon Sep 17 00:00:00 2001 From: Callum Tolley Date: Sun, 16 Nov 2025 10:35:03 +0000 Subject: [PATCH 4/4] Add Ctrl+K to the docs --- guide/src/guide/reading.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/src/guide/reading.md b/guide/src/guide/reading.md index 64624bd300..5b8f8c29bb 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 / or S key on the keyboard will open an input box for entering search terms. +Pressing the search icon in the menu bar, Ctrl+K (+K on macOS), or pressing the / or S 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.