Live data from Hacker News

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

tkainrad.dev

181–190 of 212 posts

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

#181
post #166

Earlier quoted context omitted.

Question then - what do you use functionally to replace "Escape" in your daily use? As a native English-speaking engineer, the escape button has a history of doing exactly what you're suggesting it not do going back to the beginning of computing.

The standard behavior of Esc is to abort the current interaction - which is not the same as closing the dialog. For example, if you have a dialog with a drop-down list, and open that list, Esc should close it, not the whole dialog. In this scenario, the "current interaction" is IME input. The bug is that the page intercepts Esc keypresses intended to be handled by it.

I haven't checked in a while, but I'm pretty sure the dialog has no idea that the IME is active or not. So the dialog can't handle that situation, and the browser isn't handling it either. The IME/browser should not send escape to the page when canceling an IME selection.

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

#182
post #171

Earlier quoted context omitted.

Last time I needed a new laptop (my old one died) I took a 8 hour train to travel to the Netherlands from Munich instead of back home to Berlin (where I live) just so I could visit a store that has laptops with a non German layout (US international). The only way to get a non German keyboard in Germany is to order them online and wait for a week+ (typically) for that to ship internationally (because they don't stock…

I would guess that the amount of people who care about which keyboard layout they use, don't use the local keyboard layout, and require appropriate labeling of keys (i.e. don't touch type) at the same time isn't that high. I can imagine how annoying it must be to be in that group, though.

There are few million people in Berlin. A couple of hundred of thousand of them are Turkish or Russian minorities. And another few hundred thousand expats are working in the tech industry from all over the world. Most coffee shops in my area don't even have German speaking staff; much to the annoyance of some of the locals.

Some, of those people buy locally and suffer the bad experience of dealing with a sub optimal keyboard. But a lot of them take their money abroad. Local businesses are missing out on that, which IMHO is kind of stupid.

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

#183

One of many reasons i switched from a Euro ISO layout to a QWERTY ANSI layout a while ago. It took me about 3 weeks to get comfortable with QWERTY ANSI, plus another 2 months to fully get back to my regular typing speed. 100% worth it tho if you need a bunch of special characters as you regularly do with most programming languages. Some tips: - switch out ALL you keyboards, at home, at work, on all devices - use EurK…

How did you cope with the horizontal enter key? That is the single most unpleasant thing whenever forced on ANSI. (I'm not a touch typist)

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

#184
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

No, there are at least two problems here. An application shouldn't accept ctrl+alt+n as either ctrl+n or alt+n. That is simply a bug, no way around it.

It's hardly a bug, just a bad interaction.

I would argue that the bug is implicitly pressing Control. Control is not a layer modifier.

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

#186

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…

> Windows for backwards compatibility reports 'right-alt' as 'alt+control'. Interesting because on French AZERTY we also have an "altgr" key, and while Windows considers alt-control equivalent (ie. you cant type alt-control-à as well as altgr-à to get an @), typing altgr itself never triggers ctrl or alt shortcuts, it only goes the other way.

Same with an Irish layout (which is QWERTY): AltGr+(aeiou) gets you áéíóú, but never triggers Ctrl+Alt.

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

#187
I actually made a custom MacOS Croatian keyboard layout to work around these issues.

It switches to a US layout if ctrl/lalt/cmd are pressed, including switching `Z` and `Y`:

https://github.com/ivancuric/mac-hr-sane-layout

MacOS is notoriously bad for handling international shortcuts. Eg, `Cmd+[` is back system-wide. To get [ on my keyboard I need to press `AltGr + F`. `Cmd + AltGr + F` doesn't work, of course.

Where the `[` character is on a US keyboard, I have `Š`. `Cmd + Š` also doesn't work. Manually recording a shortcut to rebind it to `Cmd + Š` also used to output `Cmd + Ctrl + Alt + F`, which seems to be fixed at some point in the last 3 years.

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

#188

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

Well, maybe you should go edit MDN because it has a giant red "DEPRECATED" at the top of keypress

https://developer.mozilla.org/en-US/docs/Web/API/Document/ke...

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

#189

One of many reasons i switched from a Euro ISO layout to a QWERTY ANSI layout a while ago. It took me about 3 weeks to get comfortable with QWERTY ANSI, plus another 2 months to fully get back to my regular typing speed. 100% worth it tho if you need a bunch of special characters as you regularly do with most programming languages. Some tips: - switch out ALL you keyboards, at home, at work, on all devices - use EurK…

How did you cope with the horizontal enter key? That is the single most unpleasant thing whenever forced on ANSI. (I'm not a touch typist)

I also switched to ANSI (with a custom software layout) after using ISO for most of my life. I prefer the wider/horizontal Enter key on ANSI. I'd sometimes accidentally hit the key above it (\), but over time it got better and now it's not a problem anymore.

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

#190

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…

Which azerty? French or Belgian? I find the Belgian one is actually very well suited to programming, with easy access to all common symbols. I can't speak to the French one, but from a quick search it does look insupportable.
Post reply on HN