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

NEW
Unassigned

Status

()

Toolkit
WebExtensions: General
P5
normal
8 months ago
17 hours ago

People

(Reporter: robwu, Unassigned)

Tracking

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

52 Branch
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

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

(Reporter)

Description

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?
(Reporter)

Updated

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

Updated

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.
(Reporter)

Comment 3

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

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
(Reporter)

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
(Reporter)

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 :(
(Reporter)

Updated

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.