-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed keyboard shortcut for indent/outdent #3835
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one potential problem with this: Tab is used to switch from field1 to field2. This is a pretty standard behavior which is also used to "iterate" over other menu entries of the UI. It might be important for accessibility reasons to keep this behavior functioning.
This old behavior would be overridden with this PR. If this PR would be merged, switching from field1 to field2 instantly throws this:
I think that's an issue.
And if you actually have ordered or unordered lists in your field, then pressing Tab to switch to field2 will indent instead. That's quite unexpected though.
Maybe a solution to this would be using Control+Tab and Control+Shift+Tab for intendation instead?
Yes, I'm afraid Tab is a non-starter, as many people use that to switch between fields. Ctrl+tab may bite us in the future if we offer a tabbed UI, since that's a common shortcut to cycle through tabs, but a brief Google seems to indicate it's not a system-wide shortcut. |
Well, sometimes you don't see the forest for the trees. Thanks @GithubAnon0000 for pointing this out. |
Alt + Tab is a system-wide shortcut on Windows for switching apps. |
Same on linux. Super+Tab is an additional common shortcut for switching apps on linux, so that won't work either. |
Thanks for the input. As we already discussed in the forum, it's really not that simple to find a combination. But I'd rather have different shortcuts for Win/Mac/Linux than a non-working shortcut on macOS. As dae pointed out, for macOS, Control + Tab and Control + Shift + Tab (using Macs Control-Button) does not seem to be a good option, if Anki were to (re-)introduce tabbed UI in the future (which I'd appreciate). How about using ⌥ Option + (Shift +) Tab for Mac? Right now, this combination switches trough the different fields, just as a plain Tab does. I guess users a using plain Tab to cycle trough the fields, so this should stay the way it is. |
Technically, there are working shortcuts on macOS for indent/outdent: However, the default behavior is to use |
Interesting, they do not work for me on macOS. (See my Anki version and system in the forum thread I referenced.) I have asked colleagues of mine to confirm, and it does not work for them either. We'd have to investigate why it works for you, but does not work for some others. |
I just installed it via
Debug Info |
Yes, that's expected behavior. This PR only aims at changing the keyboard shortcut to something that works for most keyboard layouts and languages.
Is it possible to define OS specific shortcuts in Anki with the current code? I might have missed that. If it isn't possible then I don't know whether changing the shortcut to Alt+(Shift+)Tab (or ⌥ Option+(Shift+)Tab) is a wise idea. The current shortcut works for all operating systems (if used with an english layout) but fails with other layouts like a german layout. That sounds better to me than having something work only for one OS. Since we're trying out shortcuts: I don't see why we'd have to restrict ourselves to the function keys. As I see it the main problem here is that Shift changes the key pressed (e.g. the . key becomes : with Shift pressed on a german keyboard). So why not use something like Control+Alt+, for outdent and Control+Alt+. for indent? This works on linux with my german layout – but I cannot test other OSes and layouts. |
tl;dr: Indent/outdent shortcuts did not work on macOS. Switching from
Control + Shift + .
toTab
for indent, and fromControl + Shift + ,
toShift + Tab
for outdent. Tests did pass.As discussed in this Anki forum thread, and many other older forum threads, shortcuts are not working for all systems or keyboard layouts. As Anki is widely used among language learners from different countries, the app is prone to the problem of users having switched their keyboard layout by adjusting system settings (e.g., I am switching between German, English US and Unicode Hex on my MacBook by pressing the
fn
button). Yet, even with default settings, not all keyboard shortcuts that are displayed as tooltips in the Anki app work. See the thread linked above for a non-exhaustive list of more than ten shortcuts not working on the up-to-date Anki version on macOS for other than standard English keyboard layouts, as the shortcuts are asking for keyboard combinations not possible on those keyboards.Example: Indent is tool tipped as
Control + Shift + .
, which works using a standard English keyboard layout. Yet, the.
(period) key is a so called writing system key as per W3C, and as such, the result a key press yields is different based on the keyboard layout a users is using: For standard English layout users, the key will yield a period irrespective ofShift
being pressed. For German users, pressing the period system key will yield a period only ifShift
is not pressed simultaneously. When pressingShift
as well, it will yield a colon. As such, the tool-tipped shortcut cannot be typed using some layouts, amongst them the German keyboard layout. (See more examples for this on the W3C proposed recommendation document linked at the beginning of this paragraph.)While we are working out the best solution (uniform shortcuts for all keyboard layouts? customisable shortcuts? let users select a locale in the settings? …), I thought it would not hurt to already fix the shortcut for indent/outdent.
Using
Tab
andShift + Tab
seemed to be natural options to me, as they are used for the mechanic in apps widely known, like Word, Pages, or Obsidian. Those keys are considered so called functional keys by the W3C (cf here), and as such will work on nearly all layouts. Adjusting shortcuts for other buttons is as easy—I successfully tried this with superscript by replacingControl + Shift + =
with some other combination, e.g.,Control + O
–if we were to agree on which combinations the shortcuts should have. In my opinion, the thread seems to be the right place to do that. As for this quick fix,./ninja checks
did pass for me on macOS.This is my first contribution to Anki code and the first thread in the forums I am taking part in. I am happy for feedback and advice. It would be an honour to contribute to this app that I have been a user of for many years, and no doubt will be for many more to come.