JQuery Keydown, Keypress and Keyup Event

JQuery Keydown, Keypress and Keyup Event

HTML

<input id="txtInput" type="text" />

JavaScript

$(document).ready(function () {

        $("#txtInput").keypress(
            function (e) {
                 evt = e || window.event;
  var keyPressed = evt.which || evt.keyCode
  console.log(String.fromCharCode(keyPressed));
        });});