- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −
HTMLElementObject.accessKey
On Windows, set the access key for different browsers −
Web Browser | Windows OS |
---|---|
Safari | [Alt] + accesskey |
Chrome | [Alt] + accesskey |
Firefox | Alt] [Shift] + accesskey |
Let us now see an example to implement the accesskey property on Chrome web browser on Windows −
Example
<!DOCTYPE html> <html> <body> <a id="myid" accesskey="g" href="https://www.google.com/">Google</a> <p>Get the accessKey</p> <button onclick="display()">Click and display the accesskey</button> <p id="pid"></p> <script> function display() { var a = document.getElementById("myid").accessKey; document.getElementById("pid").innerHTML = a; } </script> </body> </html>
Output
Click on the above button to display the accessKey −
Advertisements