¥Adding a reset keyboard shortcut
要向重置按钮添加键盘快捷键(就像使用任何有意义的 一样),你可以使用 accesskey 全局属性。
¥To add a keyboard shortcut to a reset button — just as you would with any for which it makes sense — you use the accesskey global attribute.
在此示例中,r 被指定为访问键(你需要按 r 加上适合你的浏览器/操作系统组合的特定修饰键;有关有用的列表,请参阅 accesskey)。
¥In this example, r is specified as the access key (you'll need to press r plus the particular modifier keys for your browser/OS combination; see accesskey for a useful list of those).
html
上面示例的问题是用户无法知道访问密钥是什么!由于修饰符通常是非标准的以避免冲突,因此尤其如此。构建站点时,请确保以不干扰站点设计的方式提供此信息(例如,通过提供易于访问的链接来指向有关站点访问密钥的信息)。向按钮添加工具提示(使用 title 属性)也有帮助,尽管这并不是一个用于辅助功能的完整解决方案。
¥The problem with the above example is that there's no way for the user to know what the access key is! This is especially true since the modifiers are typically non-standard to avoid conflicts. When building a site, be sure to provide this information in a way that doesn't interfere with the site design (for example by providing an easily accessible link that points to information on what the site access keys are). Adding a tooltip to the button (using the title attribute) can also help, although it's not a complete solution for accessibility purposes.