In Firefox, the keyCode property does not work on the onkeypress event (will only return 0). For a cross-browser solution, use the which property together with keyCode, e.g:
var x = event.which || event.keyCode; // Use either which or keyCode, depending on browser support