I wrote an event fixer plugin that's in svn that provides a whole lot of
help for keys (it makes thing like keyCode and keyChar work cross-browser,
and in keypress as well as keyup).

Check it out in the fix_events folder under plugins in jQuery's svn trunk.

-- Yehuda

On 2/6/07, Klaus Hartl <[EMAIL PROTECTED]> wrote:

Karl Swedberg schrieb:
> I just inserted the code into a test page, and it worked for me. A
> couple things you can try:
>
> 1. Make sure you include jquery.js before your keydown script.
> 2. wrap your script in a $(document).ready().
>
> So, the relevant snippet of the <head> might look like this (until you
> put the keydown script in a separate file, of course):
>
> <script src="path/to/jquery.js" type="text/javascript"></script>
>
> <script type="text/javascript" >
>
> $(document).ready(function() {
> $("#tbPageInfo").keydown(
>   function(e){
>     var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
>     alert(key);
>   }
> );
> });
>
> </script>
>
> Hope that helps.

Just a little hint from me:

var key = e.charCode || e.keyCode || 0;

is more concise and avoids duplicate code.



-- Klaus

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/




--
Yehuda Katz
Web Developer | Wycats Designs
(ph)  718.877.1325
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to