Skip to content

Feature/arrow key nav#5278

Open
abhijeetnardele24-hash wants to merge 1 commit into
vuejs:mainfrom
abhijeetnardele24-hash:feature/arrow-key-nav
Open

Feature/arrow key nav#5278
abhijeetnardele24-hash wants to merge 1 commit into
vuejs:mainfrom
abhijeetnardele24-hash:feature/arrow-key-nav

Conversation

@abhijeetnardele24-hash

Copy link
Copy Markdown

Description

This PR introduces keyboard navigation to documentation pages, allowing users to navigate to the previous or next page using the ArrowLeft and ArrowRight keys. This brings VitePress closer in parity with other documentation tools like mdbook, improving accessibility and reading efficiency for power users.

Technical Details:

  • Added a global keydown event listener in VPDoc.vue.
  • Connected the listener directly to the existing usePrevNext() composable to resolve the correct prev and next routing links.
  • Added heuristics to ensure the event listener respects user intent and prevents accidental navigations:
    • Navigation is aborted if the user is holding any modifier keys (Alt, Ctrl, Meta, Shift).
    • Navigation is aborted if the user's active focus is within an interactive text element (INPUT, TEXTAREA, SELECT, or elements with contenteditable).
    • Navigation is aborted if the event's default action was already prevented by a child component.

Linked Issues

Resolves #5221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Navigate to next / previous page with arrow keys

1 participant