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 »

Description

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.



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
StringA keyboard key.

Browser Support

element.accessKey is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.