Re: JavaScript onClick event

The Webmaster is misinformed and Jim is correct.

I recommend NOT to use the second redundant onkeypress event.  The browser
causes the onclick event to be fired when the user presses the Enter key.
If the author also adds the onkeypress event, then the browser sends two
events to the server, causing all kinds of havoc on the server.  It's the
browser's responsibility to map the mouse and keyboard events where
possible, not the author's.

And, you don't have to take my word for it, code it and test it for
yourself.

The onclick guidance given in the W3C techniques document [1] is wrong, and
I've submitted a comment to the editors, while the onclick guidance on the
Access Board [2] is more current and correct.  [There are however other
problems with the other guidance.]  Which events are currently mapped and
which events should be equivalent is not well documented anywhere and needs
to be so that browsers and authors can get in sync on what to do.  Pressure
was put on browser manufactures to provide a keyboard way to navigate (tab
to links and controls), select, and activate controls, etc.  Unfortunately
at the same time the theory was perpetuated that the author had to make the
code more device independent by adding redundant events when in fact it
caused confusion.  The W3C browser accessibility standard [3] also requires
the browser to provide a keyboard way to activate all functions (which is
correct).

[1] W3C WCAG Techniques
   http://www.w3.org/TR/WCAG10-HTML-TECHS/#directly-accessible-scripts

[2] Access Board guidance
   http://www.access-board.gov/sec508/guide/1194.22.htm#(l)

[3] W3C User Agent Accessibility Guidelines
   http://www.w3.org/TR/UAAG10/guidelines.html#gl-device-independence

Regards,
Phill Jenkins
IBM Research Division - Accessibility Center

Received on Thursday, 31 October 2002 01:47:40 UTC