Reputation: 73
There is some event listener in Thunderbird which resolves the emails address from my LDAP server when i press the UP or DOWN ARROW key. so i want to trigger that the same event through Javascript without having to physically press the up or down arrow key. How can i do this?
Upvotes: 7
Views: 22270
Reputation: 3295
I believe this is what you want (using JQuery)
var e = jQuery.Event("keyup");
// e.which is used to set the keycode
e.which = 38; // it is up
e.which = 40; // it is down
$("id_to_element").trigger(e);
If JQuery is not allowed to use, pure javascript solution is more verbose. See this answer
Note: There maybe a bug in Chrome which will hamper this. I would recommend JQuery for less headache.
Upvotes: 7