Web Extension Example Commands not working

I tried to download the Web Extension Example called Commands and it I can’t get it to run. I was able to run the Your first extension example no problem, but with Commands I get an error when I press the shortcut key in the example i.e. Ctrl+Shift+U (see below). Any thoughts? I’m running Firefox 57.0.2 if that helps. No changes were made to the original code. Thanks in advance.

[Exception… “Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIPrefBranch.setBoolPref]” nsresult: “0x80040111 (NS_ERROR_NOT_AVAILABLE)” location: “JS frame :: jar:file:///C:/Program%20Files%20(x86)/Mozilla%20Firefox/browser/omni.ja!/components/devtools-startup.js :: initDevTools :: line 403” data: no]

Note on Solution: The issue as discovered by erosman has to do with the string “Ctrl+Shift+U”, switching it to “F12” makes the script work correctly.

Can you post the actual command?
Note that is must be uppercase U and not u (I don’t know why, I found that out when trying in one of my add-ons) so "Ctrl+Shift+U"

1 Like

The command is the default one “Ctrl+Shift+U”. I should have been clearer, I’ll update the original question. Thanks.

I also get an error loading that
Key event not available on GTK2: key=“u” modifiers=“accel shift” id=“

Try changing U to something else

1 Like

I believe it’s closer. I changed the shortcut key to Ctrl+Shift+J, now I don’t get an error, but I don’t see a message in the console either when I enter the shortcut key combination (which should be something like “onCommand event received for message: command”).

Try F12 and check in its console

1 Like

I just switched the shortcut key value to “F12” and it works! It seems that the string “Ctrl+Shift+U” is the culprit.

Thank you so much for working through that with me. I’m glad the base code works and it’s not some obscure issue.

Isn’t this a bug though? I’ve just wasted a few hours trying to bind a command to various Ctrl+Shift+LETTER variants, only to discover that only function keys seem to function. The docs don’t mention anything about this and the given examples indicate that this should work.

I am using X, Y, Z, as well as Function keys in my add-ons without any problem.

Check if there is conflict with built-in ones:
https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly

Thanks for the suggestion! I’ve been trying mostly Ctrl+Shift+Z (which is reserved by Firefox, according to the link you provided, so no surprise it didn’t work) and Ctrl+Shift+X (which is supposed to be free, but isn’t).
I guess it’s working after all, even though I don’t understand why Ctrl+Shift+X isn’t working for me when running the extension with web-ext run.