Can we check which action (key combination/click) was used to open the browser action popup?

In my manifest.json file, I have:

"commands": {
   "_execute_browser_action": {
      "suggested_key": {
         "default": "Ctrl+Shift+U"

I can also open the popup by clicking on its icon, on the Firefox toolbar. Is there some code to determine which action triggered the opening (key combination or click) inside the JavaScript code of the popup window?

Did you set a default_popup in manifest.json?

Or are you using

  • browserAction.onClicked +
  • action.onClicked +

I set a default_popup in manifest.json.

I think not.

FF doesn’t pass any information to the popup, so you can’t determine how it was opened.

browserAction.onClicked +
The browserAction.onClicked handler receives an OnClickData object.
But: Pressing the key combination and clicking the icon results in the same OnClickData.modifiers (none) and OnClickData.button (0).
If the user clicks the icon while pressing a keyboard modifier, you can detect this via OnClickData.modifiers
But that’s probably not what you want.
Also: In Chrome, browserAction.onClicked doesn’t receive an OnClickData object.
So you couldn’t use this method to make a cross-browser extension.

Just curious:
Why do you want to distinguish between the key combination and a click on the icon?