I want a function to be run when a keypress occurs on a text box, so I have this code:
$(\"input[x]\").keypress(function() {
DoX();
})
if you are stuck using the keypressed for some other reason (so you cannot change to keyup as suggested) then you can get the last character typed like this:
$("input[x]").keypress(function (e) {
var c = String.fromCharCode(e.which);
//process the single character or
var textValue = $("input[x]").val();
var fulltext = textValue + c;
//process the full text
});