Live data from Hacker News

Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

tkainrad.dev

121–130 of 212 posts

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#121
This article looks at non-US but missed non-Latin where things gets worse.

Arabic, Chinese, Hebrew, Russian among others.

When set to different layout many apps ignore common actions like Cmd/Ctrl + C and you need to make sure you're using a latin layout.

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#122
post #2

It really surprised and disappointed me recently that native macOS apps have the same problem outlined here. For example, the standard system-wide ‘back’ shortcut (e.g. in Safari, Finder, Preview) is Cmd+[, but this is inoperable in many keyboard layouts that don’t have any key that produces [ without modifiers. (For context: I was writing a simple mouse gestures utility that sends that keyboard shortcut to accomplis…

One favourite of mine in this genre is applications who use both command-[ and option-command-[. On a Swedish mac keyboard, [ is on option-8, so it is impossible to type just command-[ without the option key...

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#123
post #15

On a tangent, why are non-qwerty keyboards so poorly designed for programming? And specifically, why is apple’s azerty layout so terrible? Just look at this image: https://i.stack.imgur.com/3LL8a.png Can you find the [ and ] keys? If you’re having trouble, it’s because you have to use 2 (two!) modifier keys and activate the ( or ) keys, which themselves are clumsily placed. This cannot be typed one-handed in a comfor…

It's the other way around. The keyboard was the foundation for the programming languages and shortcuts, like moving with hjkl in vim. No German keyboard user would have created a language like C with curly braces, when you would break your fingers typing this (alt 8 is {, alt 9 is }, and alt+5 is [, alt+6 is ] ). I use a US keyboard for that exact reason

Aah, this explains why we have two keyboard layouts in Poland.

Original keyboards (up until 1980s) had special polish letters like ąęśćżń on dedicated keys, and various characters like [{$ moved around.

That is called „Polish” layout.

Then, since 1990 we have „Polish (programmer’s)” , which is essentially the american keyboard and local characters hidden under alt-right.

Literally everyone uses „Polish (programmers)” now, and you just need to remember to choose this, and not the regular „Polish” in system settings :)

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#124
I mostly write in English (plus Clojure, shell, and C#), but often also in Spanish, French and Finnish. I've found that a standard QWERTY/US layout with a Compose key is the best option. It gives you a decent layout for coding and shell related characters, and all diacritics (and plenty more) are a 3 keystroke chain away (with no chording). Even when writing French, which requires a lot of accents, I find it more fluid than needing to switch to (the completely awful) AZERTY layout.

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#125

There is also a whole slew of issues with Polish characters. Polish keyboard setup relies on "right-alt" and a letter to get it's diacritics variation. Ie: 'ą' is 'right-alt'+a Windows for backwards compatibility reports 'right-alt' as 'alt+control'. Many applications developers assign key combos with no negative checks. So 'ctrl-s', typically used for save gets triggered when user wants to type 'ś'. To repeat, "righ…

Really shows how useful macs having 4 modifier keys (versus PC’s 3) is. Also the better (though not perfect) matching of scopes and modkeys: on macs, command / control / option tend to affect different system areas entirely (with command taking precedence, then control, although control and option are rarely used together).

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#126
post #19

Earlier quoted context omitted.

Seems easy to fix > Windows for backwards compatibility reports 'right-alt' as 'alt+control'. There’s your problem, right there

The backwards compatibility is for physical keyboards. So that a keyboard with just one alt can still trigger polish letters. I don't know how other OSes allow for users to trigger "right-alt" when the keyboard has only one alt character.

As a Polish Linux user I think I'd switch between mappings in this case. One for typing źdźbłos and żółws, another to interact with shortcut-heavy apps.

I actually do this on two-alt keyboards too, because I like to use either alt for shortcuts.

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#127
KeyCombiner looks very interesting. I once worked on a keyboard visualizer for vscode (https://hediet.github.io/visual-keyboard), but I was never really happy with it.

It would be nice if keyboard shortcuts were a matter of the OS and applications would expose a list of all available commands with default shortcuts...

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#129

In order to write backtick, I have to shift-click the key left to backspace and then click spacebar. Tilde ~ is similar: option-click and then space. This makes the out-of-the-box keyboard shortcut for switching window on macOS unreachable on my macbook pro. There are several default shortcuts on osx that are unreachable from international keyboards.

Perhaps you can remap tilde to some other key on the keyboard?

Re: Why keyboard shortcuts don't work on non-US layouts and how devs could fix it

#130

TL;DR. Don't use keypress, it's deprecated. Don't use 'keyCode', 'which', 'char' which are all deprecated. Do use 'key' Another issue I run into is forms that dismiss via keydown and escape. I type in Japanese which means I'm using an IME. An IME, or at least the Japanese IME, you type characters and they appear with possible completions. They haven't actually been given to the app yet. Pressing Escape cancels the co…

Thanks, going to add that to a modal today.
Post reply on HN