Hacker News new | ask | show | jobs
by alexpovel 1568 days ago
A couple years ago, I switched from German QWERTZ to a UK QWERTY keyboard (wouldn't have minded US QWERTY but the differently shaped return key seemed too foreign). I am not looking back: for programming but also general tasks, having keys like

    ` [ ] \ / { }
very easily available is a blessing. The German QWERTZ keyboard has triple occupation on some keys, which is not ergonomic and harder to type fast with.

Anyway, both Linux and Windows offer fast switching between installed keyboard layouts/languages using SUPER+SPACE. This is needed in e.g. emails, where I still need Umlauts. It's just much easier to read that way. However, switching back and forth constantly is completely overwhelming and not viable. However, in German, there are perfectly and officially (?) acceptable alternative spellings for our special "Unicode"-characters. They can be typed using plain ASCII, aka a QWERTY keyboard.

So, I wrote a script to read in any text, combined it with AutoHotkey on Windows and now have a tool that, at the touch of a button, replaces selected text using alternative spellings (gruen, Duebel, Faehre) with their correct versions (grün, Dübel, Fähre). The tool could be extended for other languages rather easily. I've been using it for over a year now and recently got to release it properly on the cheese shop:

    pip install betterletter
(https://pypi.org/project/betterletter/)

Before putting this together, I had looked around for an existing tool. To my surprise (there's always something!), I found nothing. I guess this scratches a too specific itch: using QWERTY but wanting proper spelling quickly, while remaining on QWERTY as to not have a mental breakdown and stay at full typing speed.

After writing, select everything (CTRL+SHIFT+HOME works well), hit shortcut, text will be replaced. This takes about 2 seconds, much faster than switching keyboard layouts back and forth. If this ran as a daemon with the dictionary loaded into RAM already, the script could run almost instantaneously (most of the 2 seconds is IO, reading from disk), in linear time according to the text input size.

3 comments

Check out Neo [0]. It has important signs under your strong fingers. Every time i am forced to use QWERTX i get reminded how bad it is to type on.

[0] https://neo-layout.org

Neat! I'm using QWERTY International layouts myself, where you can type umlauts and ß with special keys for modifiers (e.g. alt+u on Mac for ¨), but I still think this is a cool tool.

Looking through the repo I wondered why you would commit the complete German dictionary weighing in at over 30 MB, whereas you only need a small fraction, the words containing the umlauts (or their false matches). Surely this would be a huge performance boost?

Turns out: a whopping 30% of that dictionary are words containing "ae|oe|ue|ss|ä|ö|ü|ß". Crazy. I would not have guessed that, at all.

> Neat! I'm using QWERTY International layouts myself, where you can type umlauts and ß with special keys for modifiers (e.g. alt+u on Mac for ¨), but I still think this is a cool tool.

Yeah, I had looked into these but for some reason that didn't work. Don't remember why.

> Looking through the repo I wondered why you would commit the complete German dictionary weighing in at over 30 MB, whereas you only need a small fraction, the words containing the umlauts (or their false matches). Surely this would be a huge performance boost?

Yes! It would be performance boost. In fact, I had a "caching" sort of functionality in the tool before. The whole dictionary is shipped (because that makes it much easier and there's almost no risk of wrong-doing just copy-pasting a word list, plus it compresses well enough), but then a list containing only special characters will be generated on first use if it doesn't exist yet.

As you noted, a lot of words do contain special letters, so the "complexity" wasn't worth it to me and I removed that. Could be brought back anytime, but it's fine for now.

Just fyi, Windows will let you set a keyboard layout per window. If you like writing programs, you can write one to switch the linux keyboard layout based on active window.