Is there a technique to use an accesskey attribute on an <option> tag?
I know you can use it on a <select>, but I have a requirement to use it on an <option> within a <select>.
Example: I need to do something like this?
<select>
<option>Blah</option>
<option accesskey="5">5</option>
</select>
Thanks for your help.
Having an
accesskeyattribute on an<option>tag doesn’t validate as HTML4, but does as HTML5.I’ve made a test case on JSFiddle — accesskey 9 is assigned to the text field, whilst accesskey 2 is assigned to the second
<option>in the<select>.Firefox 5 on the Mac doesn’t focus the
<option>when you activate its accesskey (using CTRL+2 — see http://en.wikipedia.org/wiki/Access_key#Access_in_different_browsers), but Chrome 12 does (CTRL+ALT+2).Theoretically, you could write some JavaScript to listen for this specific key combination and set the
<select>’s selected option, but I’m not sure if that’s worth it, or a good idea — it might confuse users more than anything else.