JSFiddle - React, Tailwind, and code Playground
HTML
<p>Type some text in the box and see the ASCII code for each of them.</p>
<input id="box" type="text">
<br>
<p id="text"></p>
JavaScript
// Javascript code
var input = document.getElementById("box");
var p = document.getElementById("text");
input.onkeypress = function (e) {
p.innerHTML += "Key code is: " + e.which + ". Character is: " + String.fromCharCode(e.which) + ".<br>";
};
/*
// Jquery code
$("#box").keypress(function(e){
alert(e.which);
});
*/