Determine which key was pressed using jQuery

I had a requirement where I need to check which key was pressed by the User in the textbox and then take various action. So below is simple jQuery code to determine or find out which key was pressed. We are using keypress() event of jQuery to detect which key was pressed.
<input type='text' id='txtValue' />
<span id="spn">You have typed: </span>
Below jQuery code first detects the keyCode and then it converts into the character. event.keyCode will give you the ASCII value of the pressed key but if you want to show the entered character then using String.fromCharCode() method, you can get the character.
        var txt = $('#spn').text();
      $('#spn').text(txt + String.fromCharCode(event.keyCode));
See live Demo and Code.
Feel free to contact me for any help related to jQuery, I will gladly help you.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..