- Type: character
- This should be set to a character that is used as a shortcut key. This should be one of the characters that appears in the
labelattribute for the element.
On non-Macintosh platforms, the character on the element's label matching the accesskey is underlined. For example, when a menu labeled 'File' has an accesskey of 'F', the generated label will be 'File'. When the user presses a modifier key specific to the platform (eg, Control* on Windows, Command* on Macintosh) and the access key, the element will be focused and/or activated from anywhere in the window. On the Macintosh, labels are never underlined, however accesskeys can still be used by pressing the letter combined with the Command key.
*(These are the keys corresponding to event.ctrlKey and event.metaKey respectively when listening to key events)
Although the value is case insensitive, a letter with the case matching the accesskey attribute will be used if both cases exist in the label. Otherwise, if the label has two or more characters which are same as its accesskey, the first of those characters in the label will be underlined.
If a label doesn't have the specified character, the character will be appended to the label with parentheses. For example, when an accesskey of an 'Open' label is 'A', the generated label will be 'Open (A)'. However, if the last character of the label is an ellipsis or a colon, the accesskey text is inserted before them. This allows a label of 'Open…' with an accesskey of 'A', to have a generated label of 'Open (A)…'. Similarly, when the label is 'Your Name:' and the accesskey is 'B', the generated label will be 'Your Name (B):'.
It is recommended that you only use characters that appear in the label. However in some languages, for example, in Japanese, characters will not always map directly to single keys, and it is quite common to have labels which cannot have a single accesskey. For these languages, you can assign an accesskey different than any of the label characters, and the accesskey text will always be appended as described above. For consistency, this occurs for languages such as Japanese even if the labels have their accesskey characters. For example, when an the accesskey for an 'OK' button is 'O', and the accesskey for the button labeled 'キャンセル' (which means 'cancel') is 'C', the labels will be 'OK(O)' and 'キャンセル(C)'.
<vbox> <label value="Enter Name" accesskey="e" control="myName"/> <textbox id="myName"/> <button label="Cancel" accesskey="n"/> <button label="Ok" accesskey="O"/> </vbox>