Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var text = $('.nonHideableWords').textContent.split(' '),
input = $('input');
function triggerKeyboardEvent(el, keyCode)
{
var eventObj = document.createEventObject ?
document.createEventObject() : document.createEvent("Events");
if(eventObj.initEvent){
eventObj.initEvent("keydown", true, true);
}
eventObj.keyCode = keyCode;
eventObj.which = keyCode;
el.dispatchEvent ? el.dispatchEvent(eventObj) : el.fireEvent("onkeydown", eventObj);
}
for(var i=0; i<text.length; i++){
var character = text[i];
input.value = character;
triggerKeyboardEvent(input, 32)
}
@24carbon

This comment has been minimized.

Copy link

commented Mar 15, 2018

mine is not working what do you do?

@SitanHuang

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.