Closed Bug 1782660 Opened 2 years ago Closed 11 months ago

Add-ons shortcuts (commands API) does not work on non-english keyboard layout

Categories

(Toolkit :: Add-ons Manager, defect, P3)

Firefox 103
defect

Tracking

()

VERIFIED FIXED
124 Branch
Tracking Status
firefox103 --- wontfix
firefox104 --- wontfix
firefox105 --- wontfix
firefox124 --- verified

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:

  1. Created an add-on, which listens for "Ctrl+Alt+T" (using commands API), and installed it.
  2. Switched to Russian keyboard layout.
  3. 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.

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.

Component: Untriaged → Add-ons Manager
Product: Firefox → Toolkit

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.

Status: UNCONFIRMED → NEW
Ever confirmed: true

The severity field is not set for this bug.
:mixedpuppy, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(mixedpuppy)

IIRC you were going to look at this.

Flags: needinfo?(mixedpuppy) → needinfo?(tomica)

A year later the issue persists

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.
Flags: needinfo?(tomica)

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?

Flags: needinfo?(chebykin.sp)

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.

Flags: needinfo?(chebykin.sp)

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?

Depends on: 1874727

(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

Severity: -- → S3
Priority: -- → P3

While I cannot set shortcut to Ctrl-Alt-T specifically, both Ctrl-T and Alt-T work on either layouts in Chrome

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.

Flags: needinfo?(chebykin.sp)

In latest nightly shortcuts did start working as expected. Great job!

Flags: needinfo?(chebykin.sp)

Thanks for confirming! Marking as fixed (by bug 1874727).

Status: NEW → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch

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.

Status: RESOLVED → VERIFIED

It got shipped in official recently, tysm!

You need to log in before you can comment on or make changes to this bug.