accesskey attribute | accessKey property

all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize
This topic has not yet been rated - Rate this topic

Sets or retrieves the access key for the object.

Syntax

HTML<element accesskey="p" ... >
JavaScript

p = object.accessKey

Property values

Type: String

a key on an alphanumeric keyboard.

Remarks

By default, pressing an access key sets focus to an object. The object receives focus when the user simultaneously presses the ALT key and the access key assigned to an object. Some controls perform an action after receiving focus. For example, using accessKey on an input type=button causes the onclick event to fire. By comparison, applying the accessKey on a radio button causes the onclick event to fire and toggles the checked property, visibly selecting or deselecting the control.

Note  For elements that are not tab stops by default, such as a SPAN, the tabIndex property must be set on the element for the accessKey property to function.

Examples

This example uses the label object and the accessKey attribute to set focus on a text box. The label object makes it possible to underline the designated accessKey. You may also use the -ms-accelerator attribute to hide the underline until the ALT key is pressed.


<label for="fp1" accesskey="1">#<span style="text-decoration: underline;">1</span>: 
Press ALT+1 to set focus to textbox</label>
<input type="text" name="T1" value="text1" size="20" tabindex="1" id="fp1">

See also

a
abbr
address
area
article
aside
b
bdo
blockQuote
body
button
caption
cite
custom
dd
del
div
dl
dt
em
embed
fieldSet
figcaption
figure
footer
header
hgroup
hn
hr
i
img
input type=button
input type=checkbox
input type=file
input type=image
input type=password
input type=radio
input type=reset
input type=submit
input type=text
ins
kbd
label
legend
li
mark
nav
object
ol
p
pre
q
rt
ruby
s
samp
section
select
small
span
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
tr
u
ul
var
Reference
accelerator
tabIndex

 

 

Build date: 11/28/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.