accesskey
global attribute
provides a hint for generating a keyboard shortcut for the current element. The attribute value must consist of a single printable character (which includes accented and other characters that can be generated by the keyboard).
注意 : In the WHATWG spec, it says you can specify multiple space-separated characters, and the browser will use the first one it supports. However, this does not work in most browsers. IE/Edge uses the first one it supports without problems, provided there are no conflicts with other commands.
The way to activate the accesskey depends on the browser and its platform:
| Windows | Linux | Mac | |
|---|---|---|---|
| Firefox | Alt + Shift + key |
On Firefox 57 or newer:
Control
+
选项
+
key
or
Control
+
Alt
+
key
On Firefox 14 or newer: Control + Alt + key On Firefox 13 or older: Control + key |
|
| Internet Explorer |
Alt
+
key
Alt + Shift + key |
N/A | |
| Edge | N/A |
Control
+
选项
+
key
Control + 选项 + Shift + key |
|
| Google Chrome | Alt + Shift + key | ||
| Safari | N/A | ||
| Opera 15+ | Alt + key | Control + Alt + key | |
| Opera 12 | Shift + Esc opens a contents list which are accessible by accesskey, then, can choose an item by pressing key | ||
In addition to poor browser support, there are numerous concerns with the
accesskey
属性:
accesskey
value can conflict with a system or browser keyboard shortcut, or assistive technology functionality. What may work for one combination of operating system, assistive technology, and browser may not work with other combinations.
accesskey
values may not be present on certain keyboards, especially when internationalization is a concern. So adapting to specific languages could cause further problems.
accesskey
values that rely on numbers may be confusing to individuals experiencing cognitive concerns, where the number doesn't have a logical association with the functionality it triggers.
accesskey
s are present, so that they are aware of the functionality. If the system lacks a method of notifying the user about this feature, the user might accidentally activate
accesskey
。
Because of these issues, it is generally advised not to use
accesskey
s for most general-purpose websites and web apps.
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 5.2
The definition of 'accesskey' in that specification. |
推荐 | More realistic behavior described for what is implemented in reality. |
|
HTML 实时标准
The definition of 'accesskey' in that specification. |
实时标准 | No change from latest W3C HTML 5.1 spec. |
|
HTML 5.1
The definition of 'accesskey' in that specification. |
推荐 | 无变化自 HTML5 . |
|
HTML5
The definition of 'accesskey' in that specification. |
推荐 |
从
HTML 4.01 Specification
, several characters can now be set as the
accesskey
. Also, it can be set on any element.
|
|
HTML 4.01 Specification
The definition of 'accesskey' in that specification. |
推荐 |
Only supported on
<a>
,
<area>
,
<button>
,
<input>
,
<label>
,
<legend>
and
<textarea>
|
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
accesskey
|
Chrome 完整支持 Yes | Edge 完整支持 12 | Firefox 完整支持 Yes | IE 完整支持 Yes | Opera 完整支持 Yes | Safari 完整支持 Yes | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 Yes | Opera Android 完整支持 Yes | Safari iOS 完整支持 Yes | Samsung Internet Android 完整支持 Yes |
完整支持
<a>
<abbr>
<acronym>
<address>
<applet>
<area>
<article>
<aside>
<audio>
<b>
<base>
<basefont>
<bdi>
<bdo>
<bgsound>
<big>
<blink>
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<center>
<cite>
<code>
<col>
<colgroup>
<command>
<content>
<data>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<dir>
<div>
<dl>
<dt>
<element>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<font>
<footer>
<form>
<frame>
<frameset>
<h1>
<head>
<header>
<hgroup>
<hr>
<html>
<i>
<iframe>
<image>
<img>
<input>
<ins>
<isindex>
<kbd>
<keygen>
<label>
<legend>
<li>
<link>
<listing>
<main>
<map>
<mark>
<marquee>
<menu>
<menuitem>
<meta>
<meter>
<multicol>
<nav>
<nextid>
<nobr>
<noembed>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<picture>
<plaintext>
<pre>
<progress>
<q>
<rb>
<rp>
<rt>
<rtc>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<shadow>
<slot>
<small>
<source>
<spacer>
<span>
<strike>
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<template>
<textarea>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt>
<u>
<ul>
<var>
<video>
<wbr>
<xmp>
<input>
类型
<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">