I know similar questions to this have been asked before, but all of the answers I could find are either in jQuery or don't seem to work anymore. I've tried doing variations of
function send(char, elem) {
let e = new KeyboardEvent('keydown', {key: char});
elem.dispatchEvent(e);
}
but no luck. The event it dispatched and triggers the appropriate handlers, but the key is not typed if an input/textarea element is focused.