JSFiddle - React, Tailwind, and code Playground

HTML

<textarea></textarea>
<br/>
<button>
Simulate Keypress
</button>

JavaScript

var textarea = document.querySelector('textarea');

document.querySelector('button').addEventListener('click', function(){

	// programmatically trigger keypress event... ? 
	var keyEvent = new Event('keypress', {
    key: 'a',
    location: 0,
    which: 65,
    code: 'KeyA'
  });
  
  textarea.dispatchEvent(keyEvent);
  console.log(`Clicked at ${Date.now()}`)
});