I have tried the following in jQuery to trigger a keydown event into an input box:
and wonder why no keydown
event with A
and Enter
was triggered. If I do type it in and press Enter myself, the form does get submitted.
The code:
$(function () {
$("#the-input").trigger("focus");
$("#the-input").trigger(
jQuery.Event('keydown', {
keyCode: 65
}));
$("#the-input").trigger(
jQuery.Event('keydown', {
keyCode: 13
}));
$("#the-input").trigger(
jQuery.Event('keydown', {
which: 65
}));
$("#the-input").trigger(
jQuery.Event('keydown', {
which: 13
}));
});
with html:
<form id="the-form" action="some.php" method="get">
<input id="the-input" type="text" name="var">
</form>