Live data from Hacker News

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

tkainrad.dev

141–150 of 212 posts

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

#141
Another problem on international keyboards besides unexpected key-codes for symbols is that it is awkward to type them with extra AktGr or Shift. Even with Vi-based editors this an awkward problem.

So indeed avoid symbols. If the application needs more shortcuts, then use prefix keys for less frequently used shortcuts or allow the user to type commands.

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

#142
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…

[deleted]

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

#143
post #37

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…

Is there a programmatic way to figure out what letter corresponds to a given keycode without that key being pressed? Because you may have to display that info somewhere to give an indication what the user has to press.

Yes. You have to dig a bit to find these APIs, and they are OS-specific (and the scan codes reported by the OS are OS-specific too, even though most keyboards are USB HID these days).

Here is the function for macOS:

https://developer.apple.com/documentation/coreservices/13905...

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

#144

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 the default Mac US/International English/British layouts (they're almost the same as each other). Mac users are graced by an OS that actually uses the Option (Alt) key on every letter to do something useful. You can type all manner of diacritics and such without using a non-standard layout! It works great for English, German, Swedish, Spanish, French, and perhaps more.

I only wish there was good support for it on Linux and Windows. I will eventually contribute a patch to xkb to fix its version of this.

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

#146
post #73
post #37

Earlier quoted context omitted.

Is there a programmatic way to figure out what letter corresponds to a given keycode without that key being pressed? Because you may have to display that info somewhere to give an indication what the user has to press.

Not that I know of. Also, not that “alt-s” will produce an s character on a US keyboard on windows, but will not produce an s on MacOS with a US layout - alt-anything will produce all sorts of interesting characters on MacOS.

There are APIs available on all major OSs that do this. Example:

https://developer.apple.com/documentation/coreservices/13905...

My memory is that if you press option E on a Mac, the translation function reports a non-zero state but no character output. You can detect this and call the translation function again with a space to get the diacritic by itself.

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

#147
post #138

Earlier quoted context omitted.

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

I configured my terminal to copy on mouse release. This allowed to keep Ctrl-C for killing processes while I use Ctrl-V to paste with Ctrl—Shift-V configured to send the original Ctrl-V.

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

#148

> What baffles me is that the problem exists in apps used by millions of people every day, developed by gigantic corporations who pride themselves with having the best engineers in the world. Why is this baffling? Because the underlying technical issues are rather trivial! > Hint for developers: Switch your computer’s keyboard layout to something other than US to debug your application’s shortcut handling on differen…

I don't think testing with a non-US region settings and a non-English language is a huge burden. As a regular user of “internationalised” software, it's really obvious when the people who wrote it do not speak more than one language, or only considered a single-country perspective.

Monolinguals, especially those living in the United States, are a minority globally. If you're going to develop all software in the United States, please at least make it work for the rest of us.

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

#149
post #67

Earlier quoted context omitted.

I think back in the day (typewriters thru... 90s?) you wrote quoted text `like this.'

This is how both TeX and m4 do quoting by default so presumably common when they were created (mid-eighties and early seventies respectively IIRC)

It’s an ASCII approximation of the proper typography for single quotes (except when you’d use inverted quotes for some reason, not sure how common it is in English).

Similarly, LaTeX uses `` and ‘’ for double quotes because the opening and closing symbols are not the same in properly typeset texts.

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

#150
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…

Honestly that's one of the reasons I'm happy with the Logitech Craft: it lets me use a proper Azerty layout yet silent like the Apple keyboards (plus I can control both my computers from a single keyboard, but that's more an edge case).

If only it weren’t so damn expensive...
Post reply on HN