The accesskey attribute specifies a keyboard shortcut for an element.
This is a global attribute that can be applied to any HTML element.
Two <input> elements with an accesskey
attribute.
The Alt-l shortcut places focus on the input field, and Alt-s submits the form.
<form action="/tutorial/action.html">
Location
<input accesskey="l" type="text" name="location" value="Amsterdam">
<br /> <br />
<input accesskey="s" type="submit" value="Submit">
</form>
The accesskey
attribute assigns a keyboard shortcut to an element.
The accesskey value is a single character that matches a key on the keyboard.
When a key-combination is pressed, e.g. [Alt] + accesskey, the element gets activated.
Unfortunately, key combinations vary across browsers:
Note: The accesskey
attribute is a global attribute that can be applied to any tag.
<tag accesskey="key" />
Value | Description |
---|---|
key | The shortcut key character (keyboard key). |
Here is when accesskey
support started for each browser:
Chrome
|
4.0 | Jan 2010 |
Firefox
|
2.0 | Oct 2006 |
Edge
|
12.0 | Jul 2015 |
Opera
|
10.0 | Aug 2009 |
Safari
|
3.1 | Mar 2008 |