From a63a249dab56ed2cb909a3abbd251b876658489b Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 16 Apr 2026 20:43:45 +0200 Subject: [PATCH 1/2] feat: add vim (hjkl) navigation --- crates/mdbook-html/front-end/js/book.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/mdbook-html/front-end/js/book.js b/crates/mdbook-html/front-end/js/book.js index 62d7c4cc87..4d816abb4e 100644 --- a/crates/mdbook-html/front-end/js/book.js +++ b/crates/mdbook-html/front-end/js/book.js @@ -718,6 +718,7 @@ aria-label="Show hidden lines">'; } switch (e.key) { + case 'l': case 'ArrowRight': e.preventDefault(); if (html.dir === 'rtl') { @@ -726,6 +727,7 @@ aria-label="Show hidden lines">'; next(); } break; + case 'h': case 'ArrowLeft': e.preventDefault(); if (html.dir === 'rtl') { @@ -734,6 +736,22 @@ aria-label="Show hidden lines">'; prev(); } break; + case 'j': + e.preventDefault(); + window.scrollBy({ top: 80, behavior: 'smooth' }); + break; + case 'k': + e.preventDefault(); + window.scrollBy({ top: -80, behavior: 'smooth' }); + break; + case 'd': + e.preventDefault(); + window.scrollBy({ top: window.innerHeight, behavior: 'smooth' }); + break; + case 'u': + e.preventDefault(); + window.scrollBy({ top: -window.innerHeight, behavior: 'smooth' }); + break; } }); })(); From 9223fda0840568772181bf193424540db7361bd1 Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 16 Apr 2026 21:07:56 +0200 Subject: [PATCH 2/2] feat: add documentation for vim key bindings --- crates/mdbook-html/front-end/templates/index.hbs | 3 ++- guide/src/guide/reading.md | 2 ++ 2 files changed, 4 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..834b9e9395 100644 --- a/crates/mdbook-html/front-end/templates/index.hbs +++ b/crates/mdbook-html/front-end/templates/index.hbs @@ -67,7 +67,8 @@

Keyboard shortcuts

-

Press or to navigate between chapters

+

Press / or h/l to navigate between chapters

+

Press j/k or d/u to scroll the page up and down

{{#if search_enabled}}

Press S or / to search in the book

{{/if}} diff --git a/guide/src/guide/reading.md b/guide/src/guide/reading.md index 64624bd300..3f1f06645f 100644 --- a/guide/src/guide/reading.md +++ b/guide/src/guide/reading.md @@ -23,6 +23,8 @@ The **arrow buttons** at the bottom of the page can be used to navigate to the p The **left and right arrow keys** on the keyboard can be used to navigate to the previous or the next chapter. +Additionally, Vim-style key bindings (H, J, K, L, D and U) can be used for navigation. + ## Top menu bar The menu bar at the top of the page provides some icons for interacting with the book.