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; } }); })(); 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 @@
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.