View video tutorial
HTML
HTML accesskey Attribute
HTML
The accesskey attribute provides a hint to create a keyboard shortcut for the current element.
Definition and Usage
➔ The accesskey attribute provides a hint for creating a keyboard shortcut.
➔ An accesskey value can conflict with a system or browser keyboard shortcut and browser may not work with keyboard shortcut.
➔ The attribute value must consist of a single printable character.
➔ Browser support and specific key combinations vary (Ex. Alt + Shift + key in Mozilla Firefox where Alt + key in Google Chrome).
Applies to
This attribute can be used on the following element.
| Attribute | Element |
|---|---|
| accesskey | Global Attributes |
Applies to
Browser and key combinations (Windows).
| Browser | key combinations |
|---|---|
| Firefox | Alt + Shift + key |
| Google Chrome | Alt + key |
| MS Edge | Alt + key> |
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML accesskey Example</title>
</head>
<body>
<form>
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Enter Name" accesskey="u"><br><br>
<label for="password" >Password:</label>
<input type="password" id="password" name="password" placeholder="Enter Password" accesskey="p"><br><br>
<button type="submit" accesskey="s">Submit</button>
</form>
</body>
</html>
Click on the "Try it Now" button to see how it works.