Handle input key pressed event
Description
The following code shows how to handle input key pressed event.
Example
<html>
<head>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(<!-- w ww. j a va 2 s. co m-->
function() {
$("input").keypress(
function(e) {
var c = String.fromCharCode(e.which);
$("p").append($("<span/>")).children(":last")
.append(document.createTextNode(c));
$("div").text(e.which);
});
});
</script>
</head>
<body>
<body>
type some letters
<input type="text" />
<p>Add text -</p>
<div></div>
</body>
</html>