To trigger JavaScript events, like KeyDown or KeyUp, you can use the type method.

browser.type('type','typing text')

If you pass the argument slowly=True to the type method you can interact with the
page on every key pressed. Useful for testing field’s autocompletion (the browser
will wait until next iteration to type the subsequent key).

forkeyinbrowser.type('type','typing slowly',slowly=True):pass# make some assertion here with the key object :)