keyboard focus
The state of being the one element on the page that receives keyboard input, usually shown with an outline.
In more detail
Only one element has focus at a time; document.activeElement tells you which. Keyboard and screen reader users move focus with Tab, Shift+Tab and arrow keys, so every interactive control must be able to receive it and show where it is.
Example
In the browser: Only focusable elements, such as links, buttons and form fields, can take focus by default. Good focus management moves focus into a dialog when it opens and back to the trigger when it closes.Related terms
- focusable element — An element that can receive keyboard focus, such as a link, button, form field or anything with tabindex="0".
- tab order — The sequence in which elements receive focus when the user presses Tab (forward) or Shift+Tab (backward).
- :focus-visible — A CSS pseudo-class that matches a focused element only when the browser thinks a focus indicator is needed, typically for keyboard use.
- keyboard navigation — Using a page entirely with the keyboard: Tab to move between controls, Enter and Space to activate, arrow keys inside widgets, Escape to close.
- focus trap — Code that keeps keyboard focus inside a container, such as an open modal, wrapping from the last element back to the first.
- keyboard accessibility — Making every feature usable with a keyboard alone, with a visible focus indicator and a sensible order.
Taught in
- Headless Architecture: State vs Presentation Separation — Design Systems & Component Engineering
- Focus Management: Trapping, Restoration & Focus Rings — Design Systems & Component Engineering
- Keyboard Navigation Protocols: Roving Tabindex & Virtual Focus — Design Systems & Component Engineering
- Screen Reader Interactions: Live Regions & Announcement Cues — Design Systems & Component Engineering
- Event Delegation: Memory-Efficient Interaction Handlers — Frontend Architecture & Web Platform
- Pointer Events, Focus Trapping And Keyboard Accessibility — Frontend Architecture & Web Platform