Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 812003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:08:05+00:00 2026-05-15T01:08:05+00:00

I have been tasked with developing a Firefox add-on that is capable of registering

  • 0

I have been tasked with developing a Firefox add-on that is capable of registering global keyboard shortcuts (ones that will work throughout all areas of Firefox) that will open up the side-bar and execute an XMLRPC request based on previously recorded input. The idea here is that there will be many potential XMLRPC requests that the user will want to execute via a keyboard shortcut.

Currently, the add-on is capable of handling pre-defined static keyboard shortcuts via the Firefox overlay. What I would like to achieve, is to allow the user to register their own dynamic custom keyboard shortcut.

There is an add-on that currently has some of this functionality, called Keyconfig. I’m not keen on having to ask users to install a second add-on to define their own shortcuts. It also seems that using the dynamic keyboard shortcut registration method in Keyconfig would require the user to close all Firefox windows before the dynamic shortcut is made available.

What I would like to know is:

  • Is an XPCOM component the best way to register dynamic keyboard shortcuts from within a Firefox add-on?
  • Is there a way to register the keyboard shortcut so that it is immediately available to all Firefox windows, without having to close the windows beforehand?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:08:06+00:00Added an answer on May 15, 2026 at 1:08 am

    I’m not able to answer “Is an XPCOM component the best way to register dynamic keyboard shortcuts from within a Firefox add-on?“, but with the help of a work colleague, we have figured out a way to do the dynamic keyboard shortcuts and make them immediately usable.

    window.onkeypress = callback;
    

    Whilst being an egregious hack, as it will execute the callback for every keypress event that the chrome window processes; it does allow for the main Firefox chrome window to have dynamic keyboard shortcuts without necessitating a reload.

    To get this to work with the keyboard shortcuts being defined in the sidebar, I’ve created a listener in the overlay JavaScript’s init() method that listens to a custom event from the sidebar:

    init: function() {
        var sidebarElement = document.getElementById("sidebar");
    
        sidebarElement.addEventListener("fooKeyboardShortcut", function shortcutKeyListener(anEvent) {
            fooOverlay.shortcutMap = sidebarElement.contentWindow.foo.getShortcutKeysMap();
        }, true);
    },
    

    The object in the sidebar will then fire off one of these events on any state change to the map, which will cause the event listener to assign the map to the object in the Firefox overlay. The mapping key is a composite hash of the following keypress event data members:

    • altKey
    • ctrlKey
    • metaKey
    • shiftKey
    • charCode

    It is worth noting here, that keyCode can’t be used as it seems to have the value ‘0’ all the time; but charCode does have the correct value.

    The value for each key is a callback key for the sidebar object to execute the desired XMLRPC call.

    This shortcut key map is then queried for each keypress, and if there is a match; the callback key is used on a pre-registered sidebar callback

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.