Thanks for help Richard

What bugs me is that keydown should be fired once. I wonder if it
works for you guys that way.

I am using the flag. The flag will be assigned x times during the
keydown, which "works" however...

var SHIFTKEY_FLAG=false;
$(document).keydown( function(e){ if(e.shiftKey){ SHIFTKEY_FLAG=true;
console.log(SHIFTKEY_FLAG);} });
 $(document).keyup( function(e){ if(e.shiftKey){ SHIFTKEY_FLAG=false;
console.log(SHIFTKEY_FLAG);} });

Testing Peter's keydown event at
http://www.quirksmode.org/js/keys.html
results in multiple firing when the key is pressed down across common
browsers.

It is confusing, then there is no difference between keydown and
keypress.

Jan

On Jun 8, 12:18 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote:
> On 6/8/07, kotouc <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Hi,
> > my problem is that this code returns:
>
> > keydown
> > keypress
> > keydown
> > keypress
> > keydown
> > keypress
> > keydown
> > keypress
> > keyup
>
> > jQuery 1.1.2 and FF1.5
>
> > Further running:
> > $('textarea').keydown(function(e){console.log(e);});
>
> > When I press and hold the key down it keeps firing the keydown!
>
> > Jan
>
> That's an interesting finding. If you're on interested in the first keydown,
> you could set a flag on keydown and clear it on keyup and ignore the other
> repeated keydowns if that flag is set.
>
> - Richard

Reply via email to