Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

JavaScript question

detecting action keys in onKeyPress()

6:38 pm on Dec 31, 2002 (gmt 0)

Preferred Member

10+ Year Member

joined:May 24, 2002
votes: 0

I have an onKeyPress event hooked up to a textbox. I'm able to cature the letter of the normal display keys when they are pressed (I pull it from the event object), but I can't figure out how to detect whether an enter or backspace has occurred.

Any thoughts?


9:01 pm on Dec 31, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
votes: 0

As of Explorer 5 the onkeydown event fires for backspace, but not the onkeypress event. The Enter key is a flat out no-go for keypress event detection.

Not sure about Netscape/Moz/AOL etc. But IF you are going to get them to work, I'm betting you should use on keydown.