accesskey Attribute
Description
The accesskey
attribute sets one or more
keyboard shortcuts that will select the element.
Example
The following code uses accesskey
attribute in a simple form.
<!DOCTYPE HTML>
<html>
<body>
<form>
Name: <input type="text" name="name" accesskey="n"/>
<p/>
Password: <input type="password" name="password" accesskey="p"/>
<p/>
<input type="submit" value="Log In" accesskey="s"/>
</form>
</body>
</html><!-- w w w .ja v a2 s . com-->
Note
accesskey
attributes are added to three input elements.
This enables users to use keyboard shortcuts to move between used elements.
Note 2
The key combination required to trigger the accesskey setting differs between platforms.
For Windows, it is the Alt key and the accesskey value pressed together.
- press Alt+n to focus on the first input element and enter my name.
- press Alt+p to focus on the second input element and enter my password.
- press Alt+s to focus on Log In button, which submits the form.