Element property accessKey in Javascript
The element property accessKey used to specify a shortcut key to activate or set focus an element. It allows to modify and access the current value of the property.
Syntax
 1 element.accessKey
Note : avoid using key which is already specified by the browser as shortcut key.
Element property accessKey
 1 <!DOCTYPE html>
 2 <html>
 3 <body>
 4 
 5 	<h1>The Element Object</h1>
 6 	<h2>The accessKey Property</h2>
 7 
 8 	<p>The accesskey attribute specifies a shortcut key to activate/focus an element:</p>
 9 
 10 	<a id="anchor" href="https://www.iogyan.com/">IOgyan</a><br>
 11 
 12 	<p>The implementation based on browser </p>
 13 	<p>In this example, in Chrome, <b>Alt + o</b> is for https://iogyan.com.</p>
 14 
 15 	<script>
 16 	  document.getElementById("anchor").accessKey = "o";
 17 	</script>
 18 </body>
 19 </html>
In the above example, a document is created with elements that includes script element. A script element retrieve element by using getElementById() method and define shortcut for the element. When above combination of keys are pressed, it opens given page or document on browser.
Element property accessKey
Privacy Policy
Terms of Service
Disclaimer
Contact us
About us