Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Web API ButtonElement.accessKey Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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


My Personal Notes arrow_drop_up
Last Updated : 10 Feb, 2023
Like Article
Save Article
Similar Reads
Related Tutorials