views:

526

answers:

1

I am implementing a special behaviour for the Enter key. The problem is my ASP.net library generates a readonly field; and when users tab into this field (tabbing into it is meaningful; so I want that behaviour) and press Enter to submit the form, it won't submit because it's a readonly field.

I wrote a workaround that hooks up your ordinary onkeypress=checkEnter, but IE6 will still not fire this event; Firefox will.

Whan can I do to detect an Enter on an IE6 readonly field?

Thanks!

+2  A: 

For some reason IE6 won't detect pressing ENTER on the keypress event. It does however detect ENTER on the keydown and keyup events. Try the onkeyup=checkEnter instead of onkeypress. I just tested that and it works.

EDIT: According to this quirksmode article, Keypress fires when actual characters are being inserted. keyup/keydown fire on all keys. However, this behavior is different in FF and IE8.

Jose Basilio
That worked, thanks :)
Ekevoo