input tag
form tag
ATTRIBUTE: accesskey
accesskey="character"
The
accesskey
attribute allows you to designate a character on the keyboard that when pressed, along with the alt or meta key, will bring focus to an HTML element. By focus, we mean that the cursor will go to that element (for example, a link or an input box in a form).
The character can be any single character on the keyboard, including upper and lower case alphabets, numbers, symbols, or punctuation marks. You cannot repeat a character since each
accesskey
must uniquely identify an element.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML accesskey attribute example</title>
</head>
<body>
<form>
Simultaneously press the
alt
and
1
buttons and the cursor goes to the First Name input box.
<br />
Simultaneously press the
alt
and
7
buttons and the cursor goes to the Last Name input box.
<br />
Simultaneously press the
alt
and
r
buttons and the cursor goes to the Maiden Name input box.
<br />
<hr />
<br />
First Name: (accesskey = 1)
<br />
<input type="text" name="firstlname" size="30"
accesskey="1"
/>
<br />
Last Name: (accesskey = 7)
</br>
<input type="text" name="lastname" size="30"
accesskey="7"
/>
<br />
Maiden Name: (accesskey = r)
<br />
<input type="text" name="maidenname" size="30"
accesskey="r"
/>
</form>
</body>
</html>
Output:
Click to see and test output in separate window
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information