Open In App

Web API ButtonElement.accessKey Property

Last Updated : 10 Feb, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML ButtonElement.accessKey property is used to return a DOMString which is a single character representing the accessKey in the given button.

Syntax:

ButtonElement.accessKey

Return Value: This property returns a DOMString which is a single character representing the accessKey to the given button.

Example 1:

HTML




<h1 style="color:green">GeeksforGeeks</h1>
  
<h2>HTMLButtonElement.accessKey property</h2>
  
<button accessKey='g' onclick="gfg()">
    Click
</button>
<p id="gfg"></p>
<script type="text/javascript">
    function gfg() {
        var a = document.getElementsByTagName("button");
        document.getElementById("gfg").innerHTML = 'accessKey is : '+a[0].accessKey;
    }
</script>


Output:

 

Example 2:

HTML




<h1 style="color:green">GeeksforGeeks</h1>
  
<h2>HTMLButtonElement.accessKey property</h2>
  
<button accessKey='k' onclick="gfg()">
    Click
</button>
  
<script>
    function gfg() {
        var a = document.getElementsByTagName("button");
        document.write('accessKey is : ', a[0].accessKey);
    }
</script>


Output:

Web API ButtonElement.accessKey Property

Web API ButtonElement.accessKey Property

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera
  • Edge

Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads