i would like to simulate a key press in js. preferably without specifying any element.
the way i would like to do it is to use .focus() on an input and then simulate a key press like the character "a".
just the same thing that would happen if i would press the key myself.
searching through the internet i found no solution. it might have something to do with the combination of the simulated event and an input field. sometimes i can catch the events, but there is no input present in the input field.
thank you very much in advance for any help.
EDIT 1: this should not be considered a dublicate of: Is it possible to simulate key press events programmatically?
because this does not solve my problem. i have already tried it.
EDIT 2: please do not downvote this question just because you do not know how to answer it.