Javascript examples for DOM:Element accessKey
The accessKey property sets or gets the accesskey attribute of an element, which defines a shortcut key to activate/focus an element.
Set the accessKey property with the following Values
Value | Description |
---|---|
character | Sets the shortcut key to activate/focus the element |
A character from the keyboard
The following code shows how to Set the access key of a link:
<!DOCTYPE html> <html> <body> <a id="w3s" accesskey="w" href="https://www.java2s.com/">java2s.com</a> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {// ww w . j av a 2s.c om document.getElementById("w3s").accessKey = 's'; } </script> </body> </html>