Skip to content

Latest commit

Β 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

β™Ώ Keyboard Navigation Utility

A lightweight, accessible JavaScript utility that enables keyboard-only navigation across headings, links, and landmarks on any webpage β€” even as content changes dynamically.


🧠 Purpose

This utility simulates real-world keyboard navigation for users who rely on keyboard interaction (e.g., screen reader users, power users, and individuals with motor impairments). It ensures a seamless and accessible navigation experience without requiring any modifications to the existing HTML.


πŸš€ Features

  • πŸ” Automatically scans the DOM for:

    • Headings (<h1>–<h6>)
    • Anchor links (<a href="...">)
    • Landmarks (<nav>, <main>, <form>, <section>, etc. and valid ARIA roles)
  • 🎯 Keyboard shortcuts:

    • H β†’ Jump to next/previous Heading
    • L β†’ Jump to next/previous Link
    • M β†’ Jump to next/previous Landmark
  • πŸ” Directional navigation:

    • ↑ β†’ Set navigation backward
    • ↓ β†’ Set navigation forward
  • ♻️ Dynamic DOM support:

    • Updates in real time when elements are added or removed
  • πŸ–οΈ Accessibility highlighting:

    • High-contrast focus style (yellow outline, black background)
  • βœ… Works in latest versions of Chrome, Firefox, and Edge

  • πŸ“¦ No dependencies. Just one function: initKeyboardNav();


πŸ§ͺ Accessibility Principles Applied

  • Keyboard Focus: Ensures all navigated elements receive programmatic focus.
  • Visual Indicator: Provides high-contrast outline and background.
  • ARIA Support: Detects valid landmark roles (e.g., role="main", role="nav").
  • Skip Input Fields: Prevents hotkeys from interfering with typing.

βœ… Assumptions

  • All elements to be navigated are visible and part of the DOM.
  • Input fields (like , <textarea>) suppress shortcut behavior.
  • Landmarks are defined using either semantic tags or role attributes.

πŸ”§ Usage

  1. Include navigationAZ.js in your page.
  2. Call the function once:
<script>
  initKeyboardNav();
</script>

πŸ“¦ Project Structure

keyboard-navigation-utility/
β”‚
β”œβ”€β”€ navigationAZ.js    # Main standalone JavaScript utility
β”œβ”€β”€ demo.html          # Sample page with headings, links, landmarks
└── README.md          # Documentation

About

a javascript utility

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages