On 05/10/06, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote:
> >         var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
>
> Thats looks like something that could be normalized by jQuery.
>
> -- Jörn

That may be a good idea - as long as you don't change the existing
items (charCode, keyCode etc).

I have a test page for showing the various event properties related to
key presses, and have found a few things with various browsers.
http://www.texotela.co.uk/keypress.php

In Firefox:
e.keyCode return cursor keys, backspace, del/ins, home/end, PgUp/PgDown
e.charCode returns input character (A,B,C,1,2,3, &, ^ etc)

In IE:
e.keyCode returns the same as e.charCode in Firefox
The keys keyCode detects in Firefox are not detected at all in IE (so
you cannot prevent copy/paste in text boxes for example)

Opera is like Firefox, but does not use charCode (it seems to be
merged with keyCode). You get e.which in Firefox and Opera (not IE).

This is how I found out that Opera returns a keyCode (16) when shift
is pressed (other browsers don't) and it doesn't detect when ins/del
and home/end are pressed.

ctrl+A returns e.ctrlKey (true) and e.charCode (97, lowercase 'a') in
Firefox, nothing in IE and e.ctrlKey (true) and e.charCode (65,
uppercase 'a'). CapsLock has no impact on this.

I am not really sure which browser has done it 'properly' as they all
work differently.

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to