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.

BrowserWindowsLinuxMac
Internet Explorer[Alt] + accesskeyN/A
Chrome[Alt] + accesskey[Alt] + accesskey[Control] [Alt] + accesskey
Firefox[Alt] [Shift] + accesskey[Alt] [Shift] + accesskey[Control] [Alt] + accesskey
Safari[Alt] + accesskeyN/A[Control] [Alt] + accesskey
OperaOpera 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
accesskeyYesYesYesYesYes
Spread the love

Leave a Reply

avatar
  Subscribe  
Notify of