0

I have a Firefox ad-dons that activate by pressing F8.Now i want it trigger by when user focus to specific input box.other wise when input box get focused generate F8 key strocks.

$("#b_new").focusin(function () {
// Create a new jQuery.Event object with specified event properties.
var e = jQuery.Event("keydown", { keyCode: 119 });
// trigger an artificial keydown event with keyCode 119
jQuery("body").trigger( e );
});

here i got something but it does not affect to browser. i guess it's because jQuery("body").trigger( e ); do i make it as jQuery("browser_toolbar").trigger( e ); how to dot it? pls, help me to recover this problem....Thanks in advanced.....

KKR Ambir
  • 1
  • 1

1 Answers1

0
  1. The .trigger() function cannot be used to mimic native browser events. Refer this url for more details: http://learn.jquery.com/events/triggering-event-handlers/

  2. Even DOM API to create and dispatch keyboard events will not work for your case, event created will be limited to your current page only. Following is example of how to generate event using javascript.

  3. If you are comfortable with Selenium then you can use Selenium driver in choice of your language (e.g. java) to generate key events.

  4. The other option is to create another firefox extension which listen for focus event on input field of your webpages and fire keyboard events. From within extension create and dispatch keyboard events will work to simulate shortcut of other extension.

Community
  • 1
  • 1
Snehal Patel
  • 819
  • 6
  • 9