samedi 9 juin 2018

js - simulate key press without specifying an element

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.

Aucun commentaire:

Enregistrer un commentaire