HTML DOM Element accessKey Attribute
- Previous Page accessKey
- Next Page addEventListener()
- Go Back to the Previous Level HTML DOM Elements Object
Definition and Usage
accessKey
The attribute sets or returns the accesskey attribute of the element.
accessKey
The attribute specifies the shortcut key for the active or focused element.
Warning
The difficulty of using shortcut keys lies in the possibility of conflict with other key standards in the browser.
To avoid this problem, most browsers only use shortcut keys when the Alt key is pressed simultaneously.
Note
It is difficult to make shortcut keys adapt to all international languages.
The accesskey value may not appear on all keyboards.
Given these concerns, it is recommended not to use shortcut keys.
See also:
Example
Example 1
Sets the shortcut key for the link:
document.getElementById("myAnchor").accessKey = "w";
Example 2
Returns the shortcut key for the link:
document.getElementById("myAnchor").accessKey;
Syntax
Return the accessKey attribute:
element.accessKey
Set the accessKey attribute:
element.accessKey = character
attribute value
value | description |
---|---|
character | specifies the shortcut key for the active or focused element. |
return value
type | description |
---|---|
string | keyboard key. |
browser support
All browsers support element.accessKey
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page accessKey
- Next Page addEventListener()
- Go Back to the Previous Level HTML DOM Elements Object