JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="example">
<button id="start">Start auto typing</button>
JavaScript
var _keystroke_interval = 500;
var autoText = ['f','o','o','b','a','r'];
var characterIndex = 0;
var autoType = '';
$(function(){
$("#start").on('click',function(){
autoType = setInterval(function(){
$("#example").val( $("#example").val() + autoText[characterIndex] );
characterIndex++;
if (characterIndex >= autoText.length){
clearInterval(autoType);
}
},_keystroke_interval);
});
});