Javascript Reference - HTML DOM accessKey Property








The accessKey property sets or gets an access key for an element.

The following table shows how to use shortcut key 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
<




Syntax

HTMLElementObject.accessKey=accessKey

Browser Support

accessKey Yes Yes Yes Yes Yes

Example

The following code shows how to set the access key of a link.


<!DOCTYPE html>
<html>
<head>
<script>
function accesskey() {<!--from  w w  w . ja va2s .  co  m-->
    document.getElementById('myAnchor').accessKey = "w"
    document.getElementById('g').accessKey = "g"
}
</script>
</head>
<body onload="accesskey()">
<a id="myAnchor" href="http://www.example.com/">example</a><br>
<a id="g" href="http://wikipedia.org/">wikipedia.org</a>

</body>
</html>

The code above is rendered as follows: