Reputation: 11248
I am trying to test keyboard input on a TV display. I can't figure out how to get Selenium web driver to work and I don't want to bring in JQuery as a dependency. Is there a way to automate keypresses in Javascript without JQuery/Selenium?
Upvotes: 2
Views: 1364
Reputation: 962
Maybe something like this?
let elem = document.getElementById('#myInput');
elem.dispatchEvent(new Event('focus'));
elem.dispatchEvent(new KeyboardEvent('keypress',{'key':'a'}));
And possibly use it with .setTimeout()
?
Upvotes: 2