HTML DOM accessKey Property

The HTML DOM accessKey property is used to set the accessKey attribute of an element. However, the accesskey attribute in HTML is used to set a shortcut key to activate or focus on an element.

Following is the syntax to set the accessKey property −

HTMLElementObject.accessKey = char

Above, char is the shortcut key.

Following is the syntax to return the accessKey property −


On Windows, set the access key for different browsers −

Web BrowserWindows OS
Safari[Alt] + accesskey
Chrome[Alt] + accesskey
FirefoxAlt] [Shift] + accesskey

Let us now see an example to implement the accesskey property on Chrome web browser on Windows −


 Live Demo

<!DOCTYPE html>
<a id="myid" accesskey="g" href="">Google</a>
<p>Get the accessKey</p>
<button onclick="display()">Click and display the accesskey</button>
<p id="pid"></p>
function display() {
   var a = document.getElementById("myid").accessKey;
      document.getElementById("pid").innerHTML = a;


Click on the above button to display the accessKey −

Updated on: 30-Jul-2019


Kickstart Your Career

Get certified by completing the course

Get Started