Keyboard Shortcuts in Firefox Extensions: A Complete Guide
Good keyboard support separates a great extension from a mediocre one. Here's everything you need to know.
manifest.json Commands
For global keyboard shortcuts (accessible even when the extension isn't focused):
{ "commands" : { "_execute_action" : { "suggested_key" : { "default" : "Ctrl+Shift+W" }, "description" : "Open Weather & Clock Dashboard" }, "toggle-theme" : { "suggested_key" : { "default" : "Ctrl+Shift+D" }, "description" : "Toggle dark/light mode" } } }
Enter fullscreen mode
Exit fullscreen mode
Available modifiers: Ctrl , Alt , Shift , MacCtrl (Mac Cmd key)
Note: Ctrl+Alt+* combinations are blocked on Windows. Use Ctrl+Shift+* for cross-platform shortcuts.
Listening for Commands in Background
browser . commands . onCommand . addListener (( command ) => { switch ( command ) { case ' toggle-theme ' : toggleTheme (); break ; // other commands...…