jquery keypress event object keyCode for firefox problem?

You should use e.charCode in Firefox.

$("#booter").keypress(function(e){
     var code = e.charCode || e.keyCode;
     var input = $(this).val() + String.fromCharCode(code);
     $('#text').focus().val(input);
     return false;
});

Try it here:

http://jsfiddle.net/REJ4t/

PS
If you’re wondering why all this mess: http://www.quirksmode.org/js/keys.html

Leave a Comment