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?
Asked
Active
Viewed 2.0k times
7
-
Do you have code that attempts to do this, but doesn't work how you expect it to? – Shawn Bush Feb 05 '15 at 15:41
-
no i do not have code .. i wanted to know i can i simulate the up and down arrow key through javascript.. – Rishab Gupta Feb 05 '15 at 15:56
1 Answers
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.
-
Thanks Akash for the help this is exactly what i want but for javascript not for jquery. If you can please provide me some info in how can i do it through javascript. – Rishab Gupta Feb 05 '15 at 15:54
-