1
I am trying to change the keyboard shortcut for showing the context menu in Firefox (the equivalent of pressing Shift-F10
on Linux or Windows or Control-Space
on OS X). It seems like this shortcut is handled at a different level from normal keyboard shortcuts (it doesn't show up in the Keyconfig extension that allows remapping of most keyboard shortcuts).
I have tried creating key and mouse events to trigger the context menu (using the following code that is mapped to a shortcut with Keyconfig) but they haven't worked so far. I haven't been able to track down where in the source code Firefox handles the keyboard shortcut for the context menu or if there is a single function that I could call to show it.
Mouse event:
var focused = document.commandDispatcher.focusedElement;
if(!focused) focused = document.commandDispatcher.focusedWindow.document.activeElement;
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 2, null);
focused.dispatchEvent(evt);
Key event:
var focused = document.commandDispatcher.focusedElement;
if(!focused) focused = document.commandDispatcher.focusedWindow.document.activeElement;
var evt = document.createEvent("KeyboardEvent");
evt.initKeyEvent("keypress", true, true, null, false, false, true, false, 0x79, 0);
focused.dispatchEvent(evt);
Thanks for the suggestion. I did not find any relevant preference in
about:config
, but I checked on a different computer from the one I was originally using when I asked the question and discovered that I had actually made such a shortcut in Keyconfig on that computer (and I only realized this by looking inabout:config
). From that old shortcut, I produced my answer. – ws_e_c421 – 2014-02-24T19:18:16.533