[thelist] Why does this JS code work the way it does???

Matt Warden mwarden at gmail.com
Tue Dec 12 07:57:20 CST 2006

On 12/11/06, Anthony Baratta <anthony at baratta.com> wrote:
> Here's how it's put in use:
> <input type="text" class="frmInputText2" style="width: 55px"
>    id="FooElement"
>    onkeypress="return CheckNumericKeyStroke();">
> NOTE: I'm working with an IE only environment.
> Now, here's what I don't understand - why do the backspace and delete keys work in the above text input element? They should comeback with "false" and not "fire". But they do. Why? IE quirk?

Backspace and delete do not trigger onkeypress. If I recall correctly,
you need to use onkeydown in order to listen to these keys.

You may have a browser difference, according to docs.

IE:  "To invoke	Press any alphanumeric keyboard key."

Moz: "The keypress event is raised when the user presses a key on the keyboard."

Matt Warden
Cleveland, OH, USA

This email proudly and graciously contributes to entropy.

More information about the thelist mailing list