View Full Version : keypress event in DOM?

06-18-2003, 09:42 PM
DOM2 does not provide a key event module. (http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-keyevents) That's fine. I'm down with that.

According to the DOM3 Events spec (http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/events.html#Events-KeyboardEvents-Interfaces) (in last call), there's no keyPress event, only keyDown and keyUp. Instead (I guess) they've defined a new interface for text events (http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/events.html#Events-TextEvent), which provides one event type: textInput.

Should I not code event handlers for keyPress events if I wish to write DOM-compliant scripts? IE & Moz both register a keyPress; I'm sure that it won't be outphased. I worry instead about a new and better browser appearing and balking on my script because it's coded exactly to spec.

Thoughts? Opinions?

06-19-2003, 01:28 AM
Well, you're going to have to keep using keypress for a while. And then would "Uberbrowser 1.0" (when released) support non-DOM3 events? I'd say so. Mozilla supports quite a few non-DOM2 Events, and even has it's own, entirely proprietary, KeyEvent interface to make up for DOM2's lack of one.

And if not, it shouldn't take more than 10 minutes to update a script already friendly to the DOM to use the textInput event. It looks as though it should simplify most of them anyway, cutting that keyCode/charCode crap.