keyboard-navigation
它能做什么
这个技能检查页面上所有可交互的部分能否用 Tab 键操作,焦点是否按合理顺序移动。它面向希望网站无障碍的开发者和设计师。
适用场景
- ✓按钮或链接无法用 Tab 键到达的时候。
- ✓隐藏的内容仍然可以获得键盘焦点的时候。
- ✓键盘用户被困在页面某一部分无法离开的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/keyboard-navigation/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查网站上的每个控件是否都只用键盘就能操作吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会测试 Tab 顺序,检查隐藏元素是否已被移出焦点,并寻找焦点陷阱。必要时,它会建议调整 DOM 顺序或 tabindex 设置。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Enable keyboard navigation for all elements
15% of users rely on keyboard navigation—broken focus order or keyboard traps make your site completely unusable for them.
Quick Reference
- All interactive elements must be reachable via Tab key
- Focus order should follow visual reading order (left-to-right, top-to-bottom)
- Never use positive tabindex values—they break natural flow
- Hidden content must be removed from tab sequence with tabindex='-1'
- Keyboard traps are only acceptable inside active modals with a working Escape path
Check
Test that all interactive elements are keyboard accessible, focus order matches visual/reading order, hidden content is not focusable, and no keyboard traps exist except in modals with proper escape handling.
Fix
Ensure tab order follows DOM order matching visual layout. Use tabindex='-1' to remove hidden elements from focus. Avoid positive tabindex values. Ensure off-screen or display:none content cannot receive focus.
Explain
Explain how logical focus order helps keyboard users navigate efficiently, why hidden elements must be removed from the tab sequence to avoid confusion, and how focus management affects users of screen readers and switch devices.
Code Review
Review the rendered markup and interactive states that affect Enable keyboard navigation for all elements. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/accessibility/keyboard-navigation
常见问题
为什么键盘可访问性很重要?
这个技能说,许多用户依赖键盘,包括有运动障碍的人和屏幕阅读器用户。
什么情况下可以使用键盘陷阱?
这个技能说,只有在有效的 Escape 退出路径的活动模态框内才可以。
应该使用正的 tabindex 值吗?
这个技能说不应该,因为正值会打乱自然的顺序。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Enable keyboard navigation for all elements. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
热度
- GitHub 星标
- 75k
- 排名
- #2908
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。