JSFiddle - React, Tailwind, and code Playground
HTML
<input id='id' />
JavaScript
function dispatch(target, eventType, char) {
var evt = document.createEvent("TextEvent");
evt.initTextEvent (eventType, true, true, window, char, 0, "en-US");
target.focus();
target.dispatchEvent(evt);
}
var id = document.getElementById('id');
id.onkeydown = id.onkeyup = id.onkeypress = id.ontextinput = function(){console.log(arguments)}
dispatch(id, 'textInput', "a");