X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM accessKey Property

HTMLElement Object Reference Element Object

Definition and Usage

The accessKey property sets or returns an accesskey for an element.

An accesskey specifies a shortcut key to activate/focus an element.

Note: The way of accessing the shortcut key is varying in different browsers:

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, in most browsers the shortcut key can be set to another combination of keys.

Tip: The behavior if more than one element has the same access key differs:

  • IE, Firefox: The next element with the pressed access key will be activated
  • Chrome, Safari: The last element with the pressed access key will be activated
  • Opera: The first element with the pressed access key will be activated

Syntax

HTMLElementObject.accessKey=accessKey


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The accessKey property is supported in all major browsers.


Example

Example

Set the access key of a link:

<html>
<head>
<script>
function accesskey()
  {
  document.getElementById('w3s').accessKey="w"
  }
</script>
</head>

<body onload="accesskey()">

<a id="w3s" href="http://www.w3schools.com/">W3Schools</a>

</body>
</html>

Try it yourself »


HTMLElement Object Reference Element Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook