Note that there are some explanatory texts on larger screens.

plurals
  1. POSend Combination-keystrokes using sendKeyEvent in a Mozilla/Firefox Extension
    primarykey
    data
    text
    <p>I am building a Mozilla Extension and I need to send the window keystrokes using the <code>sendKeyEvent</code> function. I have it working when I send a single keystroke to the window but it is not working when I try to send a multi-keystroke pattern (ie. SHIFT+3 to send the # character). Does anyone have any idea how to send multiple keys to the window? I have tried the following code but it doesn't seem to be working:</p> <pre><code>var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils); utils.sendKeyEvent("keydown", 51, 51, 4); utils.sendKeyEvent("keypress", 51, 51, 4); utils.sendKeyEvent("keyup", 51, 51, 4); </code></pre> <p>I researched the web but I cannot find any examples of multi-key combinations.</p> <p>UPDATE:: OK so the reason why I asked this question is because I am building a custom FF extension that will interact with a website. On the website they have some shortcut keys, and in the extension I would like to trigger a couple short-cut key events. One such shortcut is the SHIFT+3 (# pound sign). So on the site I believe they have something like the following:</p> <pre><code>function key_event(evt) { if(evt.keyCode == 16) { if(evt.keyCode == 51){ FIRE EVENT } } } </code></pre> <p>Now does anyone know how I can trigger this event in javascript since the sendKeyEvent doesn't seem to trigger it? My initial thought is to create a while loop which presses the SHIFT key and setup an interval to press the 3 key. At some point they would have to be triggered at the same time? Not sure if this would be the best way. Any guidance/ideas would be greatly appreciated!</p> <p>Thanks for your time.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload