JSFiddle - React, Tailwind, and code Playground

HTML

<input id="input" />

JavaScript

var i = document.getElementById('input');
var l = i.value.length;

console.log('Initial length: ' + l);

document.onkeydown = function(e) {
    var c = String.fromCharCode(event.keyCode);
    
    if(null !== c.match(/\w/)) {
        l = i.value.length;
    }
}

document.onkeyup = function(e) {
    var c = String.fromCharCode(event.keyCode);
    
    if(null !== c.match(/\w/)) {
        if(l === i.value.length) {
            console.log("Keyboard insert might be off - length hasn't changed");
        }
    }
}