accessKey property
Browser support:Sets or retrieves an access key to an element.
The accessKey property is useful if you want to give the user an opportunity to set focus to an element using a keyboard shortcut.
Activating an access key induces additional action for some controls, e.g. in case of button, input:button, input:checkbox and input:radio elements it simulates a mouse click, so it toggles the checked state of input:checkbox and input:radio elements.
Access keys can be activated differently in different browsers:
Typically the form controls and the body object support the accessKey property.
Some other elements also support this property, but only if the tabIndex property is also specified.| Internet Explorer: | ALT + accesskey |
| Firefox: | SHIFT + ALT + accesskey |
| Google Chrome: | ALT + accesskey. |
| Safari: | ALT + accesskey. On the Mac platform, use the CTRL + accesskey combination. |
| Opera: | use SHIFT + ESC, and when the list appears, use the accesskey assigned to the element |
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
| HTML page for this property: accessKey |
Possible values:
A single character from the keyboard.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the accessKey attribute:
|
|
||||
<input type="text" value="Activate accesskey: '5'" size="30" accesskey="5" /> |
||||
|
||||
|
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the accessKey property:
|
|
||||
<head> <script type="text/javascript"> function ChangeAccess () { var input = document.getElementById ("myInput"); input.accessKey = "a"; input.value = "new accesskey: 'a'"; } </script> </head> <body> <input type="text" id="myInput" value="Activate accesskey: '5'" size="30" accesskey="5" /> <br /> Use the 'Alt' and the specified accesskey to activate the control in Internet Explorer. <br /> <button onclick="ChangeAccess ()">Change Access key to 'a'!</button> </body> |
||||
|
||||
|
Did you find this example helpful?
|
Supported by objects:
HTML elements:
a, abbr, acronym, address, applet, area, b, bdo, big, blockquote, body, br, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, h1, h2, h3, h4, h5, h6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isindex, kbd, keygen, label, legend, li, listing, map, marquee, menu, nobr, noframes, object, ol, optgroup, option, p, plaintext, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp
External links:
User Contributed Comments
