Reputation: 2593
In this line of code, the ACCESSKEY attribute yields the expected result:
<input type="button" value="Cancel" id="bDism" name="bDism" onclick="MyProc()" ACCESSKEY=a>
(other lowercase letters than a work too — haven't tried them all!). When you press ALT a MyProc is called.
Now, this one does not work
<input type="button" value="Cancel" id="bDism" name="bDism" onclick="MyPro()" ACCESSKEY=>
Could someone please explain why? (In the same form I also have an OK button with ACCESSKEY=
 — which is LF, i.e. Enter, which works although LF is a control character just as ESC is).
Upvotes: 0
Views: 1458
Reputation: 201768
The specifications do not define what characters may appear as accesskey
attribute values and what the exact functionality is. In practice, browsers support a limited set of values, typically letters and digits, in varying ways; see MDN on accesskey
.
Originally intended to promote accessibility, the accesskey
attribute has generally become a problem rather than part of a solution, partly due to incompatible implementations and due to its interference with other uses of keyboard shortcuts. See e.g. a WebAIM page on Keyboard Accessibility.
If you have some special need for keyboard commands in HTML, then using JavaScript to process keyboard events is probably a more successful approach.
Upvotes: 2