You are here: Reference > JavaScript > client-side > HTML DOM > properties > accessKey

accessKey property

Browser support:
Sets or retrieves an access key to an element.
The accessKey property is useful if you want to give the user an opportunity to set focus to an element using a keyboard shortcut. Activating an access key induces additional action for some controls, e.g. in case of button, input:button, input:checkbox and input:radio elements it simulates a mouse click, so it toggles the checked state of input:checkbox and input:radio elements.
Access keys can be activated differently in different browsers:
Internet Explorer: ALT + accesskey
Firefox: SHIFT + ALT + accesskey
Google Chrome: ALT + accesskey.
Safari: ALT + accesskey. On the Mac platform, use the CTRL + accesskey combination.
Opera: use SHIFT + ESC, and when the list appears, use the accesskey assigned to the element
Typically the form controls and the body object support the accessKey property. Some other elements also support this property, but only if the tabIndex property is also specified.

Syntax:

object.accessKey;
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: accessKey

Possible values:

A single character from the keyboard.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the accessKey attribute:
<input type="text" value="Activate accesskey: '5'" size="30" accesskey="5" />
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the accessKey property:
<head>
    <script type="text/javascript">
        function ChangeAccess () {
            var input = document.getElementById ("myInput");
            input.accessKey = "a";
            input.value = "new accesskey: 'a'";
        }
    </script>
</head>
<body>
    <input type="text" id="myInput" value="Activate accesskey: '5'" size="30" accesskey="5" />
    <br />
    Use the 'Alt' and the specified accesskey to activate the control in Internet Explorer.
    <br />
    <button onclick="ChangeAccess ()">Change Access key to 'a'!</button>
</body>
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content