Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

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




Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides