How do you mimic key strokes in a Chrome Extension?

I want to be able to mimic the events of a user typing on a keyboard within a Google Chrome Extension in much the same way that one can do it with puppeteer such that it generally fires all the same events as would a user typing manually.

Are there methods available in Google Chrome libraries to facilitate this? I have tried using JavaScript and DOM manipulations client side directly including firing off events for mouse clicks etc… This works on some pages in lieu of manual events but on a few pages that are crafty only manual and puppeteer library keyboard/mouse events accurately mimic and fire off all events.

If there is a library that facilitates this for Google Chrome Extensions I’d really appreciate someone pointing me in the right direction.

Source: Ask Javascript Questions