Menu

1 / 2

Keyboard Shortcuts in Firefox Extensions: A Complete Guide

DEV Community·Weather Clock Dash·6 months ago
#xAjTeLHA
Reading 0:00
15s threshold

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...…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.