Course contentsShow
← Web Development
Lesson 1080 of 2,98219. Keyboard Navigation and FocusFree lesson

Home and End Key Support

Moving focus to first and last items in navigable groups.

Home and End Key Support

You'll learn how to let users jump instantly to the first or last item in a navigable group using Home and End keys.

What Are Home and End Keys?

Think of these keys as an express elevator in a tall building—instead of going floor-by-floor (arrow keys), you can jump straight to the top floor (End) or ground floor (Home). In keyboard navigation, these keys provide shortcuts to reach boundary items in lists, menus, toolbars, and grids instantly.

Why This Matters

When a user is navigating a toolbar with 20 buttons using arrow keys, reaching the last button means pressing the arrow key 19 times. The End key should jump them straight there. This is an expected behavior for keyboard-only users and screen reader operators—omitting it creates frustration and inefficiency.

The Implementation Pattern

When you detect a Home key press (event.key === 'Home'), move focus to the first focusable item in your group. When you detect End (event.key === 'End'), move focus to the last focusable item. You'll typically call preventDefault() to stop the browser from scrolling the page, since you're handling the navigation yourself.

This pairs perfectly with the roving tabindex pattern you've already learned: Home and End move focus between boundary items, while arrow keys handle step-by-step navigation in between.

Common Use Cases

  • Horizontal toolbars: Home focuses the leftmost button, End the rightmost
  • Vertical menus: Home focuses the top item, End the bottom
  • Tab lists: Jump between first and last tabs
  • Grid navigation: Home/End can move to row boundaries

Key Takeaway: Home and End keys provide essential shortcuts for keyboard users to jump to boundary items in navigable groups—always implement them alongside arrow key navigation for complete accessibility.