7

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?

Rishab Gupta
  • 73
  • 1
  • 1
  • 3

1 Answers1

7

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.

Community
  • 1
  • 1
a_pradhan
  • 3,285
  • 1
  • 18
  • 23