JSFiddle - React, Tailwind, and code Playground
HTML
<input id="a" type="text" />
<button id="left">Go Left</button>
CSS
input {
font-size: 1.5em;
padding: 10px;
}
JavaScript
$("a").focus();
$("left").addEvent("click", function() {
$("a").focus();
(function() {
var keyEvent = document.createEvent("KeyboardEvent");
var keyLocation = '0x00';
var keyIdentifier = 'U+00'+options.keyCode.toString(16);
keyEvent.initKeyboardEvent("keypress",
true,
true,
window,
keyIdentifier,
keyLocation,
false);
$("a").dispatchEvent(keyEvent);
}).delay(1000);
});