English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The 'accesskey' global attribute provides a way to generate shortcut keys for the current element. The attribute value must contain a printable character.
Usage of accesskey:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>基础教程网(oldtoolbag.com)</title> </head> <body> <form> <input type="text” name="name" value="enter your name:" size="25" maxlength="30" accesskey="n"> <u>n</u>ame<br><br> <input type="password" name="passwd" size="25" maxlength="30" accesskey="p"> <u>p</u>password<br><br> <input type="text" name="address" size="25" maxlength="30" accesskey="a"> <u>a</u>address<br><br> <input type="radio" name="sex" value="male" accesskey="m" checked><u>m</u>male<br> <input type="radio" name="sex" value="female" accesskey="f"> <u>f</u>female<br> </form> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
All mainstream browsers support the 'accesskey' attribute
The 'accesskey' attribute specifies the shortcut key that activates (focuses) the element.
Note: The ways to access shortcut keys vary in different browsers on different operating systems:
Browser | Windows | Linux | Mac |
---|---|---|---|
Internet Explorer | [Alt] + accesskey | N/A | |
Chrome | [Alt] + accesskey | [Alt] + accesskey | [Control] [Alt] + accesskey |
Firefox | [Alt] [Shift] + accesskey | [Alt] [Shift] + accesskey | [Control] [Alt] + accesskey |
Safari | [Alt] + accesskey | N/A | [Control] [Alt] + accesskey |
Opera | Opera 15 or newer: [Alt] + accesskey Opera 12.1 or older: [Shift] [Esc] + accesskey |
However, in most browsers, the shortcut keys can be set to a different combination.
Tip: Usage of accesskey shortcut keys in various browsers:
IE browser
Press the Alt key, click the shortcut key defined by accesskey (the focus will move to the link), then press Enter.
FireFox browser
Press Alt+Shift key, click the shortcut key defined by accesskey.
Chrome browser
Press the Alt key and click the shortcut key defined by accesskey.
Opera browser
Press the Shift key and click esc, a list of accesskey shortcuts defined on this page will be displayed for selection.
Safari browser
Press the Alt key and click the shortcut key defined by accesskey.
In HTML5 In HTML, the accesskey attribute can be used for any HTML element (it will Validate any HTML element. But it may not be useful).
In HTML 4.01 In HTML, the accesskey attribute can be used for: <a>, <area>, <button>, <input>, <label>, <legend>, and <textarea>.
<element accesskey="character">
Value | Description |
---|---|
character | Shortcut key for activating the specified element |