Live data from Hacker News

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

tkainrad.dev

131–140 of 212 posts

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

#131

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 flu…

I like to use the qwerty US international. Far better than the Azerty layout which is indeed completely awful.

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

#132
post #82
post #63

Earlier quoted context omitted.

We all suffer from character blindness of some sort. For you: ` - that thing isn't formally defined in English either as far as I know. In English we don't have any diacritics. We do have a few extra symbols, beyond the alphabet for certain situations. Quotations ... " ... meh should be 66 99 and that will be fixed up by DTP software. We use ' to denote a dropped letter - abbreviation. There are a few others. I won't…

It's the grave accent - pretty rare in English outside of loan words from other languages. https://en.wikipedia.org/wiki/Grave_accent#English

Touché

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

#133
post #28

As a kid, I remember being utterly confused, when most games with a console would have the key ` to open it. WTF is the key ` and where is it? For a kid it wasn't that easy to understand that there are such things as different keyboard layouts. Turns out that ` is a single key press to the left of the '1', in English, while it is a bit obscure character to write in other languages. In mine, you have º and ª in that p…

I remember that too. But the console you only open sometimes. But everyday(!), I have to use {[(| ... and they are just awkward to reach on a german layout.

Yeah, sorry but the continental European keyboard maps with those keys in the number row suck. There's no ifs or buts about that.

I have learned on the US keyboard and keep using it more or less.

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

#134

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…

Not sure if I agree with this summary of my article. For most web apps with relatively few keyboard shortcuts, I would actually recommend to use keypress. keyCode/which/charCode work when used with keypress.

The article mentions an open-source example that does it this way and works fine on international layouts: Discourse

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

#135
post #3

> For example, on my German layout, / is produced via Shift+7. This is my #1 annoyance with German keyboards as someone who learned a UK layout and who needs to do lots of programming and terminal hacking (#2 is the swapping of Y and Z). I take it this layout was invented before Unix and its heavy use of forward slashes, but it does show how shortcuts are rather discriminatory. I know more than a few Germans who use…

I'm Chilean and I use the ANSI US layout because /, are much easier to type than using ISO keyboards. When I need to type Spanish characters like áéíóú, ñ, etc. I switch to latin american ISO layout using WIN + Spacebar and then switch back.

The British/Irish ISO layouts are reasonable. They are very close to the US layout, but gain the additional key.

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

#136
post #113

They had me until: > This means when the key combination is alt+/, the shortcut should be triggered when a german layout user presses alt+shift+7. No way. I want to press alt+dash, which is in the same place as alt+/ on a US keyboard. Pressing alt+shift+7 is the equivalent of Lee-Harvey-Oswald-grade marksmanship on a keyboard.

The problem is, most people will not know that alt+dash is an alternative for alt+/ with their layout. Also, it does not actually work with all browsers and operating systems. Try to use dash as a replacement for / in Firefox and you will be disappointed.

However, developers defining and documenting alt+/ as an alternative for alt+/ when registering the binding would indeed be a fine solution.

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

#137

The best solution would be to actually allow users to change the keyboard shortcuts on the software they use.

Absolutely, that would be a fine solution. It is also mentioned in the article. I really don't know why web application developers are not doing it. Especially when you could be the first to do it and have a real edge over your competitors.

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

#138

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).

I do like Cmd+c vs Ctrl+c on a mac. On linux I've changed my terminal to use Ctrl+Shift+c instead of Ctrl+c for ^C because I kept accidentally killing programs when trying to copy text with Ctrl+c which works in every app except terminals...

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

#139
post #34

The author spends a lot of time explaining the APIs that have been deprecated but doesn’t say which one is the correct one to use now...

Unfortunately, it's not that simple. For different apps, different approaches might be best. That's why there is a section on possible solutions.

Regarding events, attributes, and deprecation: keydown (event), code (attribute), and key (attribute) are not deprecated.

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

#140
post #36

It's not just international keyboards that are affected by this. I'm a Dvorak user so I run into these issues from time to time. As the article explains, there is a difference between the physical keyCode and character it corresponds to. Which to use really depends on what it is being used for, and there are situations for both. The article suggests checking the character typed, but this is not always the correct way…

> For instance, the most annoying are games which default to WASD based on the letter typed and not the physical keys Is it even possible to do anything else? I can’t imagine keyboards report their physical layout..

Normally, keyboards report data to the computer which represents the location of a key on a standard keyboard. The OS translates to characters based on configured layout. The actual letters printed on the key caps are just decorative.

If you type WASD on a US layout USB keyboard, the computer will receive key codes 26, 4, 22, 7.

If you type ZQSD on a French keyboard you get exactly the same result.

So if you are writing a game, you might listen for codes 26, 4, 22, 7 and these will be in the sample place on the keyboard regardless of layout. You can ask the OS to translate these codes to letters for help text.

(Some of the details here are omitted—the codes above are USB HID codes, but those go through an additional OS-specific translation table before they are sent to your program.)

Post reply on HN