HTML DOM Element accessKey
Example
Set the access key of a link:
document.getElementById("myAnchor").accessKey = "w";
Try it Yourself »
Return the accesskey of a link:
document.getElementById("myAnchor").accessKey;
Try it Yourself »
Definition and Usage
The accessKey
property sets or returns the accesskey attribute of an element.
The accessKey
property specifies a shortcut key to activate or focus an element.
Warning
Using accesskeys is difficult because they may conflict with other key standards in the browser.
To avoid this problem, most browsers will use accesskeys only if pressed together with the Alt key.
Concerns
Adapting accesskeys to all international languages is difficult.
The accesskey value may not be present on all keyboards.
Because of these concerns, it is advised not to use accesskeys.
See Also:
Syntax
Return the accessKey property:
element.accessKey
Set the accessKey property:
element.accessKey = character
Property Value
Value | Description |
character | Specifies the shortcut key to activate/focus the element. |
Return Value
Type | Description |
String | A keyboard key. |
Browser Support
element.accessKey
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |