Gregory Hill
2006-Jan-27 15:52 UTC
RE: [prototype] [BUG] Event.stop doesn''t stop allkeystrokes on some browsers
> a little more digging into this and it appears it''s that different > browsers > handle the keypress at different times (from what I can see, there are3> events triggered when you press a key, keydown, keypress, and keyup).I> changed line 1531 to ''keypress'' from keydown and on all of thebrowsers I> tested (safari, opera, konqueror) it appeared to work fine, with the > exception of opera, which still allowed the tab key through. >That''s good to know. I was wondering why my capturing of the Enter key was not working on Opera. It worked on IE and Firefox, though. I had something along these lines: Event.observe(input, ''keypress'', function(event) { if (event.keyCode =Event.KEY_RETURN) { Event.stop(event); /* more code */ return false; } }); And that prevented the form from submitting in everything except Opera, although I didn''t test Safari. Let me know if you figure out a way to stop Opera. Btw, the keydown event isn''t what fires the form submission, which is why capturing it didn''t work. Event.stop only stops THAT event, not subsequent events. So, keydown fires, you stop it, then keypress fires (which initiates the form submission, at least in most browsers), then keyup fires. At least, that''s my understanding of it. Greg