<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>keypress demo</title>
<style>
fieldset {
margin-bottom: 1em;
}
input {
display: block;
margin-bottom: .25em;
}
#print-output {
width: 100%;
}
.print-output-line {
white-space: pre;
padding: 5px;
font-family: monaco, monospace;
font-size: .7em;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<form>
<fieldset>
<label for="target">Type Something:</label>
<input id="target" type="text" value="">
</fieldset>
</form>
<script type="text/javascript">
$("#target").keypress(function(event) {
if (event.which == 13) {
event.preventDefault();
console.log(event);
}
});
$('#target').on('keypress', function(event) {
event.preventDefault();
switch (event.which) {
case 13:
console.log(13);
break;
}
});
</script>
</body>
</html>