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
18 changes: 18 additions & 0 deletions crates/mdbook-html/front-end/js/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@
}

switch (e.key) {
case 'l':
case 'ArrowRight':
e.preventDefault();
if (html.dir === 'rtl') {
Expand All @@ -726,6 +727,7 @@
next();
}
break;
case 'h':
case 'ArrowLeft':
e.preventDefault();
if (html.dir === 'rtl') {
Expand All @@ -734,6 +736,22 @@
prev();
}
break;
case 'j':
e.preventDefault();

Check failure on line 740 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
window.scrollBy({ top: 80, behavior: 'smooth' });

Check failure on line 741 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
break;

Check failure on line 742 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
case 'k':
e.preventDefault();

Check failure on line 744 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
window.scrollBy({ top: -80, behavior: 'smooth' });

Check failure on line 745 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
break;

Check failure on line 746 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
case 'd':
e.preventDefault();

Check failure on line 748 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
window.scrollBy({ top: window.innerHeight, behavior: 'smooth' });

Check failure on line 749 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
break;

Check failure on line 750 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
case 'u':
e.preventDefault();

Check failure on line 752 in crates/mdbook-html/front-end/js/book.js

View workflow job for this annotation

GitHub Actions / GUI tests

Expected indentation of 12 spaces but found 10
window.scrollBy({ top: -window.innerHeight, behavior: 'smooth' });
break;
Comment on lines +739 to +754
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These scroll actions always use behavior: 'smooth'. For users who prefer reduced motion, this can be an accessibility issue. Consider detecting prefers-reduced-motion: reduce and using behavior: 'auto' (or omitting behavior) when reduced motion is requested.

Copilot uses AI. Check for mistakes.
Comment on lines +739 to +754
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scroll behavior is duplicated across four cases and introduces a magic number (80). This will be harder to tune consistently later. Consider extracting a small helper (e.g., scroll(delta)) and defining named constants for the line-step and page-step to centralize the behavior.

Copilot uses AI. Check for mistakes.
}
});
})();
Expand Down
3 changes: 2 additions & 1 deletion crates/mdbook-html/front-end/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
<div id="mdbook-help-popup">
<h2 class="mdbook-help-title">Keyboard shortcuts</h2>
<div>
<p>Press <kbd>←</kbd> or <kbd>→</kbd> to navigate between chapters</p>
<p>Press <kbd>←</kbd>/<kbd>→</kbd> or <kbd>h</kbd>/<kbd>l</kbd> to navigate between chapters</p>
<p>Press <kbd>j</kbd>/<kbd>k</kbd> or <kbd>d</kbd>/<kbd>u</kbd> to scroll the page up and down</p>
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second line lumps j/k (small increments) and d/u (page-sized increments) together as “scroll up and down”. To avoid confusion, consider clarifying that j/k scroll by a small step and d/u scroll by roughly one page.

Suggested change
<p>Press <kbd>j</kbd>/<kbd>k</kbd> or <kbd>d</kbd>/<kbd>u</kbd> to scroll the page up and down</p>
<p>Press <kbd>j</kbd>/<kbd>k</kbd> to scroll a small amount, or <kbd>d</kbd>/<kbd>u</kbd> to scroll roughly one page</p>

Copilot uses AI. Check for mistakes.
{{#if search_enabled}}
<p>Press <kbd>S</kbd> or <kbd>/</kbd> to search in the book</p>
{{/if}}
Expand Down
2 changes: 2 additions & 0 deletions guide/src/guide/reading.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (<kbd>H</kbd>, <kbd>J</kbd>, <kbd>K</kbd>, <kbd>L</kbd>, <kbd>D</kbd> and <kbd>U</kbd>) can be used for navigation.
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line says the Vim-style keys are used for “navigation”, but in the implementation j/k/d/u scroll rather than navigate between chapters. Also, the doc displays uppercase keys, while the key handler matches lowercase ('h', 'j', etc.), which may mislead users into holding Shift. Recommend updating the text to distinguish chapter navigation (h/l) vs scrolling (j/k and d/u), and either show lowercase in the guide or add uppercase cases in the handler.

Suggested change
Additionally, Vim-style key bindings (<kbd>H</kbd>, <kbd>J</kbd>, <kbd>K</kbd>, <kbd>L</kbd>, <kbd>D</kbd> and <kbd>U</kbd>) can be used for navigation.
Additionally, Vim-style key bindings can be used: <kbd>h</kbd> and <kbd>l</kbd> navigate to the previous and next chapter, while <kbd>j</kbd>, <kbd>k</kbd>, <kbd>d</kbd>, and <kbd>u</kbd> scroll the current page.

Copilot uses AI. Check for mistakes.

## Top menu bar

The menu bar at the top of the page provides some icons for interacting with the book.
Expand Down
Loading