Simulate a key in a field


Well-known member
Here what I have:

There is an input field and a button.
I click on the button, and a text "example" is copied to field.


I also gave the focus to that field.
And now I have to press [space] to have a key-event on my field (then something else happens)
But I am lazy, I want to have this key-event also by script:

    var e = jQuery.Event("keydown");
     e.which = 32;
     e.ctrlkey = false;

This does not work.

Any idea, what I can do instead?
Finally solved with:

function setFieldInputByButton($myText)
You could save yourself future work/headache by not using jQuery.

Top Bottom