HTML accesskey Attribute

The accesskey attribute specifies a keyboard shortcut for an element. This is a global attribute that can be applied to any HTML element.

Example

#

Two <input> elements with an accesskey attribute.
The Alt-l shortcut places focus on the input field, and Alt-s submits the form.

Location  

<form action="/tutorial/action.html">
   Location &nbsp;
   <input accesskey="l" type="text" name="location" value="Amsterdam"> 
   <br /> <br />  
   <input accesskey="s" type="submit" value="Submit">   
</form>

Using accesskey

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:

  • Chrome, Edge, Safari, and Opera use [Alt] + accesskey.
  • Firefox uses [Alt] [Shift] + accesskey.

Note:  The accesskey attribute is a global attribute that can be applied to any tag.


Syntax

<tag accesskey="key" />

Values

#

Value Description
key The shortcut key character (keyboard key).

Browser support

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

You may also like



Guides