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

Anthony Baratta anthony at baratta.com
Tue Dec 12 10:57:30 CST 2006

OK...That makes sense. Anywhere I can find info like that regarding down / up / press? e.g. Browser acts on down versus up, etc.

I'm not interested in changing the behaviour because it works as intended - I just didn't want the code to be a "magic happens here" type of function. Besides, knowing the why helps in solving other problems later. ;-)

-----Original message-----
From: "Lee kowalkowski" lee.kowalkowski at googlemail.com
Date: Tue, 12 Dec 2006 05:31:02 -0800
To: "Anthony Baratta" anthony at baratta.com, "thelist at lists.evolt.org" thelist at lists.evolt.org
Subject: Re: [thelist] Why does this JS code work the way it does???

> On 11/12/06, Anthony Baratta <anthony at baratta.com> wrote:
> > Normally I can tear into a piece of code and figure out what it's doing. But I can't quite see why this JS function is working exactly the way it does. Here's the function, my comments follow:
> > <input type="text" class="frmInputText2" style="width: 55px"
> >   id="FooElement"
> >   onkeypress="return CheckNumericKeyStroke();">
> >
> > 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?
> The browser will receive and act upon the onkeydown events for
> Backspace, Enter, F5, etc..., you're waiting for the onkeypress event,
> too late I'm afraid.  Change it to onkeydown.
> -- 
> Lee

More information about the thelist mailing list