[commands] Explicit support for overriding built-in keyboard shortcuts by WebExtensions




WebExtensions: General
8 months ago
17 hours ago


(Reporter: robwu, Unassigned)


(Depends on: 2 bugs, Blocks: 1 bug)

52 Branch
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [design-decision-approved] triaged)



8 months ago
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/commands says the following:

> If a key combination is already used by the browser (for example, "Ctrl+Shift+R"), or by an existing add-on, then you can't override it. You will be allowed to define it, but your event handler will not be called when the user enters it.

This appears to not be true in Firefox. I don't see any logic that checks whether the shortcut is already registered at http://searchfox.org/mozilla-central/source/browser/components/extensions/ext-commands.js

Moreover, I created an add-on that successfully blocks the default actions of the Ctrl-Q and Command-Q shortcuts (which normally cause Firefox to quit) by registering Ctrl+Q/MacCtrl+Q and Command+Q in manifest.json: https://addons.mozilla.org/en-US/firefox/addon/disable-ctrl-q-and-cmd-q/

Can you confirm that this is the expected behavior, and if so, update the documentation?


8 months ago
Summary: commands API documentation → commands API documentation incorrectly asserts that default shortcuts cannot be overridden


7 months ago
Flags: needinfo?(amckay)

Comment 1

7 months ago
I just removed that paragraph based on your add-on. I think we should probably think about if we want to have a permission for overriding built-in commands, so altered the bug title accordingly.
Flags: needinfo?(amckay)
Priority: -- → P5
Summary: commands API documentation incorrectly asserts that default shortcuts cannot be overridden → Prevent overriding built in keyboard shortcuts
Whiteboard: [design-decision-needed] triaged

Comment 2

6 months ago
I think simply overriding is always a bad idea, even if there is a permission. Firefox should finally get a proper UI for configuring keyboard shortcuts where conflicts are visible and resolvable in a clever way.

Comment 3

6 months ago
+1 for a better UI. Follow bug 1287093 for it.

Comment 4

6 months ago
I believe that with a proper UI (or API), it should be possible to allow WebExtensions to override the shortcut. So I'm adding bug 1240350 and bug 1320332 as dependencies.
Depends on: 1303384, 1320332

Comment 5

6 months ago
Bug 1303384 is about providing a UI for re-assigning command shortcuts. Probably the only thing this adds to that bug is showing the built in commands so you can see when a shortcut is overriding a build in shortcut.
Whiteboard: [design-decision-needed] triaged → [design-decision-approved] triaged

Comment 6

6 months ago
Adjusted summary to more accurately reflect the purpose of the bug.
Summary: Prevent overriding built in keyboard shortcuts → [commands] Explicit support for overriding built-in keyboard shortcuts by WebExtensions

Comment 7

5 months ago
Ctrl-Q cannot be overridden on Linux - https://addons.mozilla.org/en-US/firefox/addon/disable-ctrl-q-and-cmd-q/reviews/854938/

This behavior is inconsistent across platforms :(


4 months ago
See Also: → bug 1267145
Blocks: 52821
You need to log in before you can comment on or make changes to this bug.