Ok, eso es algo

window.dispatchEvent(new KeyboardEvent('keypress', {
  'key': 'a'
}));
Friendly Hawk