Add-ons shortcuts (commands API) does not work on non-english keyboard layout
Categories
(Toolkit :: Add-ons Manager, defect, P3)
Tracking
()
People
(Reporter: chebykin.sp, Unassigned)
References
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0
Steps to reproduce:
- Created an add-on, which listens for "Ctrl+Alt+T" (using commands API), and installed it.
- Switched to Russian keyboard layout.
- Pressed "Ctrl+Alt+T"
Actual results:
Nothing
Expected results:
An event should be sent to the add-on, so in my case a new tab should have opened. On English layout everything works as expected. Built-in shortcuts, such as "Ctrl+T" and others work fine on either layouts.
Comment 1•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Toolkit::Add-ons Manager' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 years ago
|
||
Hello,
I reproduced the issue on the latest Nightly (105.0a1/20220803212830), Beta (104.0b5/20220802185803) and Release (103.0.1/20220729222726) under Windows 10 x64.
I used a couple of add-ons to test this, Tree Style Tab and Dark Reader and changed the default shortcuts to toggle some functions to Ctrl+Alt+T.
As such, with the English keyboard layout enabled, I was able to trigger the functions of the add-ons via the shortcut I set up. However, after switching to the Russian keyboard layout, I was unable to trigger the add-on functions via the shortcut.
Comment 3•2 years ago
|
||
The severity field is not set for this bug.
:mixedpuppy, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 4•2 years ago
|
||
IIRC you were going to look at this.
Reporter | ||
Comment 5•1 year ago
|
||
A year later the issue persists
Comment 6•11 months ago
|
||
I'm able to reproduce this in a Windows 10 VM, Firefox 121.0. I installed a simple add-on that has a shortcut (https://addons.mozilla.org/en-US/firefox/addon/display-_anchors/), then visited this bug. The default shortcut (Alt-Shift-A) triggers the expected behavior.
Then I visited about:addons, clicked on the settings icon, "Manage Extension Shortcuts". I switched to Ctrl-Alt-T
. On an English keyboard layout, the shortcut works as expected. As soon as I switch to a Russian keyboard layout, it stops working. When I switch back to Alt-Shift-A, the shortcut works. When I switch to Ctrl-Alt-T, the UI in about:addons gives the impression that the shortcut is registered, but when I try the shortcut, nothing happens.
At the registration of the Ctrl-Alt-T shortcut while the Russian keyboard layout is active, the global browser console displays the following warning:
Key event not available on some keyboard layouts: key=“t” modifiers=“accel,alt” id=“”
The shortcut handling is not add-on specific, we rely on the <key>
element inserted in every browser window, created by buildKeyFromShortcut
in ExtensionShortcuts.sys.mjs. There is no significant difference in the output, when I add a logpoint printing keyElement.outerHTML
, the result is:
- Broken:
<key xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" modifiers="accel,alt" key="T"/>
- Works:
<key xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" modifiers="alt,shift" key="A"/>
Because the extension-side registration of the shortcut is not doing anything special, this looks like an issue with the ability to detect the shortcut internally. The console warning is emitted by https://searchfox.org/mozilla-central/rev/7fc94186f1a759790c56e41a90ab350d78dbda30/dom/events/KeyEventHandler.cpp#606-613
I'm wondering about the next steps here:
- Should the internals somehow map latin keyboard "shortcuts" to the corresponding key on non-English keyboards? If yes, that could be a task for Core :: DOM: UI Events & Focus Handling.
- (If not: ) Should the shortcut management page of
about:addons
support non-latin shortcut keys? If yes, that could be an actionable task in the component here.
Comment 7•11 months ago
|
||
To help with informing the path towards the resolution... could you clarify your expectations?
When a Russian keyboard layout is used (e.g. https://en.wikipedia.org/wiki/JCUKEN), there are no latin characters on the keyboard. How do you expect something like Ctrl + Alt + T
to work? How would a user know which keys to press?
Reporter | ||
Comment 8•11 months ago
|
||
To be honest, have never seen a Russian keyboard without latin letters. For example, Latin T (as fifth key in qwerty) is always coupled with Russian E (fifth in ЙЦУКЕНГ). AFAIK keyboard only sends keycodes, and it is up to OS to interpret those. So one way to do it would be tying shortcuts to their keycodes assuming latin qwerty layout. Another way would be introducing layout-specific shortcuts, and defaulting them to the above.
Reporter | ||
Comment 9•11 months ago
|
||
Well that's already the potential resolutions you mentioned. I don't mind either. How do more basic shortcuts (like Ctrl-T) manage to work regardless the layout though?
Comment 10•11 months ago
|
||
(In reply to chebykin.sp from comment #9)
Well that's already the potential resolutions you mentioned. I don't mind either. How do more basic shortcuts (like Ctrl-T) manage to work regardless the layout though?
I have no idea.
(In reply to chebykin.sp from comment #8)
So one way to do it would be tying shortcuts to their keycodes assuming latin qwerty layout. Another way would be introducing layout-specific shortcuts, and defaulting them to the above.
I sketched this idea at the end of comment 6. Given your confirmation of this as a reasonable approach, I have gone ahead and filed bug 1874727.
Do you have Chrome? How does Chrome behave with keyboard shortcuts here? They too have an extension API to register shortcuts, you can find them at chrome://extensions/shortcuts
. If you need a simple extension with shortcut functionality, see https://chromewebstore.google.com/detail/display-anchors/poahndpaaanbpbeafbkploiobpiiieko
Reporter | ||
Comment 11•11 months ago
|
||
While I cannot set shortcut to Ctrl-Alt-T specifically, both Ctrl-T and Alt-T work on either layouts in Chrome
Comment 12•11 months ago
|
||
Can you try Nightly and let us know if your issue has been fixed?
I reported the underlying issue at bug 1874727, which has been fixed today.
Reporter | ||
Comment 13•11 months ago
|
||
In latest nightly shortcuts did start working as expected. Great job!
Comment 14•11 months ago
|
||
Thanks for confirming! Marking as fixed (by bug 1874727).
Comment 15•11 months ago
|
||
Verified as Fixed. Tested on the latest Nightly (124.0a1/20240124211633) under Windows 10 x64 and Ubuntu 22.04 LTS.
Tested with Dark Reader where I changed the “Toggle extension” function shortcut to Ctrl+Alt+T. The shortcut works as expected now both with an English layout keyboard as well as a Russian layout, confirming the fix.
Updated•10 months ago
|
Reporter | ||
Comment 16•9 months ago
|
||
It got shipped in official recently, tysm!
Description
•