WebExtensions命令快捷键能否自定义?咨询suggested_key修改方法及规划
Great questions! Let's break this down clearly:
1. Are WebExtensions command shortcuts customizable?
Absolutely! Users have full control to customize command shortcuts for installed WebExtensions, regardless of the suggested_key set by the developer.
All major browsers (Chrome, Firefox, Edge, etc.) offer a native interface for this:
- Chrome: Navigate to
chrome://extensions/shortcuts - Firefox: Go to
about:addons, click the gear icon, then select "Manage Extension Shortcuts" - Edge: Visit
edge://extensions/shortcuts
On these pages, users can override any suggested keys with their preferred combinations, as long as they don’t conflict with existing browser or system shortcuts.
2. How to modify the suggested_key from the commands documentation?
The suggested_key is a developer-defined default set in your extension’s manifest.json during development. It can’t be dynamically modified after the extension is installed (either by the extension itself or via user-facing code).
To set or update suggested_key as a developer, edit your manifest.json directly. Here’s an example:
{ "manifest_version": 3, "name": "My Extension", "version": "1.0", "commands": { "trigger-custom-action": { "suggested_key": { "default": "Ctrl+Shift+X", "mac": "Command+Shift+X" }, "description": "Run my custom extension action" } } }
After updating the manifest, reload the extension in your browser’s developer mode for changes to take effect. For published extensions, you’ll need to push an update with the modified manifest to the extension store—users will get the new suggested key when they update, though they can still override it in their browser’s shortcut settings.
Users can’t edit suggested_key directly via the extension’s UI; they must use the browser’s native shortcut management page mentioned earlier.
3. Will there be future support for modifying suggested_key dynamically?
As of now, none of the major browsers have announced plans to add API support for dynamically modifying suggested_key post-installation. The current model prioritizes user control, letting users set shortcuts through native browser tools rather than allowing extensions to alter defaults after being installed.
If you’re a developer wanting this feature, you can submit feedback through the respective browser’s developer channels (like Chrome’s crbug.com or Firefox’s bugzilla.mozilla.org), but there’s no public timeline for such functionality to be implemented.
内容的提问来源于stack exchange,提问作者Alexey Romanov

