What is HTML accesskey Attribute?

HTML, HTML Attributes , , 0 Comments

Global accesskey attribute provides a hint for the current element to generate a keyboard shortcut.

The value of the attribute must be a single printable character (including accented and other characters that the keyboard can generate)

In separate browsers, the manner to access the shortcut key varies.

As this is the part of HTML global attributes you can use this on any HTML tag.

Browser Windows Linux Mac
Internet Explorer [Alt] + accesskey N/A
Chrome [Alt] + accesskey [Alt] + accesskey [Control] [Alt] + accesskey
Firefox [Alt] [Shift] + accesskey [Alt] [Shift] + accesskey [Control] [Alt] + accesskey
Safari [Alt] + accesskey N/A [Control] [Alt] + accesskey
Opera Opera 15 or newer: [Alt] + accesskey
Opera 12.1 or older: [Shift] [Esc] + accesskey

However, the shortcut can be put to another key mix in most browsers.

Example

<p>If you want to save the 
  <strong><u>S</u></strong>ettings 
  press the below button
</p>

<button accesskey="s">Save</button>
<button accesskey="c">Cancel</button>

Note: 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.

Browser Support

Attribute
accesskey Yes Yes Yes Yes Yes

Leave a Reply

Your email address will not be published. Required fields are marked *