JavaScript Element accessKey Property Tutorial

In this section, we will learn what the Element accessKey property is and how to use it in JavaScript.

What is Element accessKey Property in JavaScript?

The JavaScript Element accessKey property is used to set or get the accesskey attribute of an element.

Basically, using this property, we can set a shortcut key for an element in JavaScript.

Note: please check the HTML accesskey section if you’re not familiar with this attribute.

Element accessKey Property Syntax:

element.accessKey;

element.accessKey = value;

Element accessKey Property Input Value

The value we put for this property is the name of a key on the keyboard that users can select to get the focus to the target element.

Element accessKey Property Return Value

This property will return the access-key of an element in a form of string (basically this value is a character). Or an empty string if the target element does not have any key associated with it.

Example: using element accessKey Property in JavaScript

See the Pen using element accessKey Property in JavaScript by Omid Dehghan (@odchan1) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies