Wrong shortcut for indentation on German keyboard still not fixed

Hello there!

I am using Anki on an M1 Mac with the German keyboard layout.
The Keyboard shortcut still isn’t displayed properly.

This issue is now at least three years old and still unresolved.
This issue was raised on Reddit and on the Forums (once for Linux) and still is not fixed (for Mac at least). I would love to share the Links to relevant discussions on Reddit and the forums, but the forum doesn’t let me.

I would love to assist anyone who wants to resolve this issue, please let me know.

Anki version:
Anki 24.11 (87ccd24e)
Python 3.9.18 Qt 6.6.2 PyQt 6.6.1

Cheers
Carlos

1 Like

It says Ctrl+Shift+. for me (using linux), but that doesn’t seem to be working. Ctrl+Shift+, for “Einrückung verringern” doesn’t work for me either.

What is the right shortcut? I could probably correct it in the translation tool, since I’ve got an account for that.

Edit: I don’t believe this is a translation mistake. My laptop has a different keyboard layout then the standard german keyboard my computer uses. On my standard keyboard increasing intendation works with Ctrl+Shift+<. I cannot do that with my nonstandard laptop keyboard.

If I remember correctly there is an addon that shows the keyboard shortcuts that anki uses and allows one to change those shortcuts. Would be great if anki would natively support that or if the shortcuts where dependend on the actual keyboard layout.

1 Like

Hey Anon, thank you very much for the reply and generous offer!
Here are the correct and working shortcuts. They were posted by
u/maturoto on a Reddit post concerning this issue.

For u/NekoServant and anyone coming back to this later on, here is what works on a German Mac keyboard:

  • indent: ⌘ + ⇧ + < (i.e., ⌘ + >)
  • deindent: ⌘ + <
    I found this by googling for a UK Mac keyboard and figuring out which characters are actually triggered when you press ⇧ + ./⇧ + , on there. Turns out they are >/<, so I just replicated that on a German keyboard.

I validated this answer, it works!

Cheers!
Carlos

Thanks. Regarding that, please see my edit in the post above.

Thanks for the reply, but it’s still wrong for Mac users using the built-in keyboard on a MacBook, isn’t it?

Well, it’s also wrong for me using my built in laptop keyboard.
The layout is different. It’s not about the translation if the keyboard layout is wrongly detected (which is the reason the shortcuts don’t work).

E.g. on my laptop I have to press Fn+L to get a < key. But that would mean I’d have to Ctrl+Shift+Fn+L on my keyboard, which anki doesn’t recognize at all. So it’s not the tooltip that’s the issue, but the actual assignment of which keys can be used. If I use my standard PC keyboard on my laptop, it works fine (because the layout of the PC keybaord is different).

That’s why I wrote this:

I hope that makes sense. Maybe some programmer / anki staff sees this and opens an issue on github.

A few things I found:

Here’s the addon to change keyboard shortcuts: https://ankiweb.net/shared/info/24411424 (@NameLessGO mentioned it here).

There had been similiar (still open) bug reports like this one here:

Maybe event.code needs to be changed to event.key like it had been done here:

Not sure though.

(btw, you tagged this as “translating”. That’s the reason why I say that it’s not a translating error, but rather something that should be solved on a code level)

Also see

Thank you very much for your thorough reply and the excellent explanation for the problem. I changed the flair!

1 Like

Yes, new users are limited in the links they can post. But you can give us them as plain text if you put them in between `backticks` in preformatted-text-block. It will help to see what issues you think are related to each other.

This sounds like another instance of how shortcuts interact with keyboard layouts other than English-International. Sometimes you need to use the keys for where those characters would be on the English Layout.

I had similar results with the Turkish-Q layout. For more background:

1 Like

Hi people! I ran into the same issue that @carlosr had. I am using the German keyboard layout as well (but Intel Mac, ⁨Anki v24.11 (87ccd24e) with Python 3.9.18 Qt 6.6.2 PyQt 6.6.1).

Regarding keyboard shortcuts overall:
I had this issue before, tried to find a solution, but the Anki team said it would not be a priority. I can see that there may be tasks that have a higher priority. But we should at least add a GitHub issue for this specifically, so that it doesn’t get lost. As far as I can tell, there is a general issue #1508 regarding the way keyboard shortcuts work (and a more recent one, specifically regarding French layout, #2440). But there is a difference between doing what is discussed there and fixing the wrong helpers or adjusting for common keyboard layouts, so that they work (as an interim solution). A settings section to reassign shortcuts would be nice, but I guess it’s a lot of work to be done.
I argue we should, for the time being, at least remove the shortcut helpers (that tell me to press some shortcut that doesn’t work), so that people are not confused. Or, if possible, at least get the shortcuts running (at least for the languages most commonly used, which I assume German is, among others).

Regarding the problem itself:
For me, some keyboard shortcuts (e.g., “Command+,” to open settings) do work, others do not. Especially the intend ones do not work, neither using German keyboard layout nor US keyboard layout. I tried the add-on that @Anon_0000 suggested above, which was mentioned by @NameLessGO, but I had no success with this either. So there seems to be some general problem with how the keys are recognized/evaluated, just as discussed in GitHub issue #1508.

If a more specific issue is created and tagged in GitHub accordingly, maybe someone would be able craft a fix and propose a pull request.

Yours -T
PS: This is my first post on this forum, feel free to PM me if I should adjust this post in any way to make it more precise, etc.

2 Likes

I wholeheartedly agree, it should be independent of the keyboard layout used.

This is good as a workaround but not a solution.

I wish I understood more about programming to solve this. I do think that I found the culprit though, which is the way keys are handeled here:

2 Likes

@tommylenz @Anon_0000
Hopefully you both clicked through to my earlier Turkish-Q thread – which includes a discussion (albeit unresolved) between devs about what the limitations are regarding shortcuts, and what solutions might/might not be possible.

I wonder if my response there apply similarly to German.

QShortcut really isn’t the problem though. For example in addcards.py QShortcut is used and to my knowledge works for every keyboard layout (see line 121).

In the add cards window on the other hand the shortcut for intendation doesn’t work, which expects Ctrl+Shift+.. As said in my comment above, I believe shortcuts.ts is the issue.

As a proof of concept I tested it out. In addcards.py (l. 139) another shortcut is used, set with QKeySequence as above and which is supposed to show the added cards history. Here’s the original code of the addcards.py shortcut for the history:

        # history
        b = bb.addButton(f"{tr.adding_history()} {downArrow()}", ar)
        if is_mac:
            sc = "Ctrl+Shift+H"
        else:
            sc = "Ctrl+H"
        b.setShortcut(QKeySequence(sc))
        b.setToolTip(tr.adding_shortcut(val=shortcut(sc)))
        qconnect(b.clicked, self.onHistory)
        b.setEnabled(False)
        self.historyButton = b

I changed the sc = "Ctrl+H" part so that it says sc = "Ctrl+Shift+." and rebuild anki. The result is that this shortcut works (anki knows how to process it, unlike the same shortcut used for intendation which is not handeled by QKeySequence) and the tooltip changes accordingly too:


So why does the same shortcut not work for intendation? Because the shortcut for the intendation is using some custom logic, which probably doesn’t account for non english keyboard layouts.

The file extension of shortcuts.ts .ts indicates that it’s typescript. So if my knowledge is correct, that’s basically javascript. And in javascript the keyboard layout is correctly identified and used if event.key is used. event.code on the other hand shows the problem anki currently has (where you’d have to use the keys where the keys would be on the english layout). See the documentation I linked above.

Edit: I do know that ankis code doesn’t really use this exact function but it makes it easier to explain why the custom code might not work properly.

The custom logic anki uses for the intendation (and others) is way above my skill level though and while I’m not 100% sure that that file is the root cause of the problem, I would say that I do believe it’s a likely culprit.

I’d also like to add that translating the tooltip is absolutly not necessary and not the way to go. The shortcut should stay the same, always. But anki needs to be able to understand that the user pressed the correct shortcut keys (e.g. Ctrl+Shift+.), not just the correct location on the keyboard. What I mean by that is this: imagine the standard QWERTY layout. If a shortcut y existed and was mapped to some function, e.g. opening stats, I’d have to press y on a QWERTY keyboard to open stats. On that same position where the y in the QWERTY keyboard would be, there’s a z instead on a QWERTZ layout. A user with a QWERTZ layout wouldn’t press z though, just because the letter y would be on that position in an english layout. So if a user pressed y on a QWERTZ layout (where a z would be on a QWERTY layout), then anki needs to know what key has been pressed, not the code that might change for every layout (again, see documentation of event.key and event.code linked above). So it’s not an issue with translating tooltips, but an issue with the underlying code itself.

In the topic you linked someone mentioned that the russian keyboard doesn’t have a @ key readily available. Such conflicts would have to be resolved either by allowing to customize shortcuts keys or by using a shortcut that doesn’t have this kind of issue (though the first one is probably best, since there are a lot of keyboard layouts and even more of them that do not follow the standards).

2 Likes

@Danika_Dakika Yes I did, thanks for the previous work, it gave good insights. It applies somewhat similar to German layout. If I understand your thread over there correctly, you say you are able to indend and outdent when using the buttons on Turkish layout keyboards that would in the physical position of the buttons on English International layout. For me at least (German/up-to-date macOS), this is not the case. Neither can I indent with the short cut that is described in the label nor with the one that uses the keys in the physical position of the described short cut.
I haven’t tried this with others since posting, but maybe I find the time on the weekend to do so, and will post a list if this makes tracking the problem easier.

I’m with dae at least for the part that we should use Shift in the labels, as at least Mac users (irrespective of them using the browser or app version) will expect the label to be something like ⌘ > for indend and ⇧ ⌘ > for outdent, just like dae used ⌘ A and ⇧ ⌘ A in his example. This seems to be convention, at least on Apple systems.

The discussion in this thread was, as far as I can tell, about the logic of how things work. I wanted to add—with my post above—that I think it would be best to at least do something in the meantime, preferably enabling users with “non-standard” layouts to indend etc. somehow, or at least disable the shortcuts that don’t work. Yet, @Anon_0000 did point out that this is not so much about QShortcuts as was suggested in the other post, but rather about the custom logic, which I cannot say for sure but sounds reasonable, as @Anon_0000 definitely is right about the event.key and event.code thing. When I looked into shortcuts.ts after he posted earlier, this is what struck me as well. I was like “Why won’t it work, since event.key is recognizing the keys I press just fine?”. I tried it using a dummy JS script and it worked for all layouts I use. I, too, saw that there was a lot of custom logic in this file. Without any JSDocs etc., I could not understand how the whole system works at first glance.
Thanks @Anon_0000 for trying out the proof of concept already. I will try this as well as soon as I find the time (sadly I have important tests ahead). Maybe all of us can tackle this problem together and fix it.

1 Like

Quick addendum: Something that is bugging me since switching from Qt5 Anki to Qt6 Anki somewhen during 2024 (due to add-on incompatibility it took me quite some time) is that some keyboard shortcuts have changed. Right now, I can create an ordered list with ⌘ ., using the German layout. In Qt6, ⌘ , will open Anki’s settings. In Qt5, it used to create an unordered list. I prefer it to open the settings, as this is convention for all macOS apps. But (1) the label is wrong in telling me that this is still the correct keyboard shortcut and (2) we need some other keyboard shortcut to create an unordered list. In fact, this is what the following shortcuts do for me right now on German layout with the builtin MacBookPro German keyboard (⌘ is command, ⌥ is alt for Mac):

  • ⌘ , opens settings (label says unordered list)
  • ⌘ . creates ordered list (as the label says)
  • ⌘ - nothing
  • ⌘ < nothing
  • ⇧ ⌘ , (= ⌘ ;), ⌥ ⌘ ,, and ⌥ ⇧ ⌘ , nothing
  • ⇧ ⌘ . (= ⌘ :), ⌥ ⌘ ., and ⌥ ⇧ ⌘ . nothing
  • ⇧ ⌘ - (= ⌘ _), ⌥ ⌘ -, and ⌥ ⇧ ⌘ - nothing
  • ⇧ ⌘ < (= ⌘ >), ⌥ ⌘ <, and ⌥ ⇧ ⌘ < nothing
  • ⇧ ⌘ + (= ⌘ *) is superscript (label says superscript is ⌘ =, but on German layout the = is no plain key but rather ⇧ 0 → In this case, pressing the “would be” button (in my case the asterisk) does work, but it doesn’t for the indent ones, see above
  • ⇧ ⌘ 0 (= ⌘ =) is subscript (label says subscript is ⌘ ⇧ =, which is not possible with the Germany layout, see above) → This is funny, because pressing the shortcut ⌘ = should, according to the label, apply superscript but instead applies subscript :smiley:
  • ⌥ ⇧ 5 does correctly apply strikethrough (labelled as alt+shift+5)
  • Indent is labelled as command+tab, but that is a keyboard shortcut used by macOS systemwide for the App Switcher
  • Outdent is labelled as command+shift+tab is also used for the App Switcher and is not recognized by Anki

One more thing: By Apple convention, one would label ⇧ ⌘ 0, not ⌘ ⇧ 0, as Anki does. While this won’t make a huge difference, we could, when fixing, adjust that.

Hello,
I am facing the following issue:
The Hotkey for the Bullet Points is CTRL and , on windows and it works there. Using CMD and , on Mac is not working for me since this is a system default for settings for the app you are using so when pressing it the Anki preferences come up. Is this a known issue? I know I can use an add on to fix this but I think this could be helpful for everyone therefore posting it here.

1 Like

Are you using a keyboard layout other than US/International-English?

Yes I am using the german layout.

Same problem m3 mac with german keyboard. Would be nice if it could be fixed. the superscript and subscripts don’t work properly too.

1 Like

I wanted to investigate but hit a problem that I cannot understand: Changing and removing `SuperscriptButton.svelte` has no effect at all. Why?
Once someone can help me to understand this, I’ll continue my investigation.

@tommylenz sent a list of things that don’t work for him, which I’ll be using as a base (even though I use linux, but I should be able to reproduce a few of them).

2 Likes