December 2013
Intermediate to advanced
384 pages
9h 54m
English
$("input[type=text]").on("keypress", function(){ $("#p1").html("Key Pressed"); }); $("input[type=text]").on("keydown", function(){ $("#p1").html("Key is Down"); }); $("input[type=text]").on("keyup", function(){ $("#p1").html("Key is Up"); });
JavaScript provides three events that are triggered when a key is pressed on the keyboard: keydown, keypress, and keyup. These events allow you to capture each keystroke into the text input.
For example, if you want to add an event handler that is triggered each time a key is pressed in text input, you could use the following:
$("input[type=text]").on("keypress", function(){handler_code}); ...
Read now
Unlock full access