JSFiddle - React, Tailwind, and code Playground

HTML

Type here:<br/>
<input type="text" id="field"/>
<br/><br/>
Output using <em>fieldCode</em>:<br/>
<input type="text" id="fieldcode"/>
<br/><br/>
Output using <em>key</em>:<br/>
<input type="text" id="key"/>

JavaScript

$("input:first").focus();
$(document).keyup(function(e){
        
        key=e.which;
    
        fieldCode=$("input#field").val().charCodeAt(0);
    
        alert('event.which='+key+'\n\ncharCodeAt='+fieldCode);
    
        $("input#field").val('');
        $("input#key").val(String.fromCharCode(key));
        $("input#fieldcode").val(String.fromCharCode(fieldCode));
    
});