accesskey快捷键
One of the principles of accessibility is that making websites accessible benefits everyone, not only people with differing abilities. In the past, I’ve used the accesskey
attribute to enhance forms, but relatively few web developers appreciate that accesskey
can also be used on tags other than <label>
, most especially links, in a way that benefits both experienced users and those requiring keyboard shortcuts.
可访问性的原则之一是,使网站可访问使所有人受益,而不仅仅是具有不同能力的人。 过去,我曾使用accesskey
属性来增强表单 ,但很少有Web开发人员意识到accesskey
还可以用于除<label>
以外的其他<label>
,尤其是链接,从而使有经验的用户和需要键盘快捷键。
There is a loose standard for accesskey
values for site site navigation; 1 is generally used for the Home page, 3 for Site map, 4 for search, 0 for help, etc. These can be added directly to <a>
tags in navigation:
站点导航的 accesskey
值有一个宽松的标准; 1通常用于主页, 3用于站点地图, 4用于搜索, 0用于帮助,等等。这些可以直接添加到导航中的<a>
标记中:
<nav role="navigation">
<a href="index.html" accesskey="1">Home</a>
<a href="about.html" accesskey="2">About</a>
<a href="map.html" accesskey="3">Site Map</a>
<a href="search.html" accesskey="4">Search</a>
<a href="help.html" accesskey="0">Help</a>
</nav>
The keyboard combos for accesskey shortcuts differ slightly across browsers and platforms:
在不同的浏览器和平台上,用于快捷键快捷键的键盘组合略有不同:
Browser | Operating System | Modifier | Example |
---|---|---|---|
Internet Explorer / Chrome / Safari | Windows | Alt | Alt + 0 |
Firefox | Windows | Alt + SHIFT | Alt + SHIFT + 0 |
Firefox / Safari | Mac | Ctrl | Ctrl + 0 |
Chrome | Mac | Ctrl + Opt | Ctrl + Opt + 0 |
浏览器 | 操作系统 | 修饰符 | 例 |
---|---|---|---|
Internet Explorer / Chrome / Safari | 视窗 | Alt键 | Alt + 0 |
火狐浏览器 | 视窗 | Alt + Shift | Alt + Shift + 0 |
火狐浏览器 | 苹果电脑 | Ctrl | Ctrl + 0 |
Chrome | 苹果电脑 | Ctrl + Opt | Ctrl + Opt + 0 |
I’ve added access keys on the site you’re reading now; feel free to try them out.
我已经在您正在阅读的网站上添加了访问密钥; 随时尝试。
Key | Function |
---|---|
1 | Home page |
S | Focus cursor in search input |
4 | Initiate search |
0 | About |
. (period) | Go to next page |
, (comma) | Go to previous page |
键 | 功能 |
---|---|
1个 | 主页 |
小号 | 将光标放在搜索输入中 |
4 | 开始搜寻 |
0 | 关于 |
。 (期) | 转到下一页 |
, (逗号) | 转到上一页 |
Two final points of note:
最后两点注意事项:
accesskey
values must be unique on the page in which they are used; as navigation will still be present on a form page, this means greater restrictions on whichaccesskey
values are available for form elements.accesskey
值在使用它们的页面上必须是唯一的; 作为导航仍然将存在一个形式页面上,这意味着更大的限制在其上accesskey
值可用于表单元素。Ideally
accesskey
values should be visually indicated in the navigation, using the same CSS techniques you would use for form labels.理想情况下,应该使用与表单标签相同CSS技术在导航中直观地指示
accesskey
值。
更多资源 (More resources)
As I mentioned, accessibility for websites has not yet gained the same level of appreciation or structure as HTML5 or other W3C standards, although adoption is increasing, albeit very slowly. There are several recommended resources:
正如我提到的那样,尽管可访问性的增长速度非常缓慢,但其可访问性尚未达到与HTML5或其他W3C标准相同的赞赏或结构。 有几种推荐的资源:
WebAIM (Web Accessibility In Mind) is the leader in promoting web accessibility standards. Their WAVE (Web Accessibility eValuation Tool) is one of the best for “validating” the accessibility of a web page.
WebAIM (头脑中的Web Accessibility)是促进Web Accessibility标准的领导者。 他们的WAVE (网络可访问性评估工具)是“验证”网页可访问性的最佳工具之一。
Broadly speaking the EU has been ahead of the rest of the world in supporting web accessibility standards, officially adopting the W3C's Web Content Accessibility Guidelines 1.0 as the standard that all government pages should meet.
从广义上讲,欧盟在支持Web无障碍标准方面一直领先于世界其他地区,正式采用了W3C的Web Content Accessibility Guidelines 1.0作为所有政府页面都应满足的标准。
At a practical level, the W3C is developing WAI 2.0 standards (Web Accessibility Initiative). More (rather technical) information can be found on the WAI site.
在实践上,W3C正在开发WAI 2.0标准(Web Accessibility Initiative)。 可以在WAI网站上找到更多(技术性的)信息。
翻译自: https://thenewcode.com/189/Creating-Accesskey-Shortcuts-For-Site-Navigation
accesskey快捷键