跳到正文
Skillpedia
网站与界面(前端)75k · #2908

keyboard-navigation

它能做什么

这个技能检查页面上所有可交互的部分能否用 Tab 键操作,焦点是否按合理顺序移动。它面向希望网站无障碍的开发者和设计师。

适用场景

  • ✓按钮或链接无法用 Tab 键到达的时候。
  • ✓隐藏的内容仍然可以获得键盘焦点的时候。
  • ✓键盘用户被困在页面某一部分无法离开的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/keyboard-navigation/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/keyboard-navigation/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2908
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能