December 2013
Intermediate to advanced
384 pages
9h 54m
English
$("input[type=text]").on("keypress", function(e){ var s = "You Pressed "; if (e.ctrlKey){ s += "CTRL + "; }; if (e.altKey){ s += "SHIFT + "; }; if (e.shiftKey){ s += "SHIFT + "; }; s += String.fromCharCode(e.charCode); $("#p1").html(s); }); });
The event passed to the event keyboard event handler includes the character code and the auxiliary key information. To determine which key was pressed, use the event.charCode attribute to get the character code. You can convert the character code to a character using the String.fromCharCode(code) method. For example:
var charcter = String.fromCharCode(event.charCode);
To determine ...
Read now
Unlock full access