The curious case of the disappearing Polish S

A fascinating deep dive into a bizarre keyboard bug on Medium that prevented Polish users from typing the letter 'ś', tracing its roots back through decades of history, hardware limitations, and OS quirks.
The curious case of the disappearing Polish S
One keyboard bug three decades in the making
A few weeks ago, someone reported this to us at Medium:
"I just started an article in Polish. I can type in every letter, except ś. When I press the key for ś, the letter just doesn’t appear. It only happens on Medium."
This was odd. We don’t really special-case any language in any way, and even if we did… out of 32 Polish characters, why would this random one be the only one causing problems?
Turns out, it wasn’t so random. This is a story of how four incidental ingredients spanning decades (if not centuries) came together to cause the most curious of bugs, and how we fixed it.
Ingredient 1/4: Polish language
Polish is the second most-used Slavic language, right after Russian and just before Ukrainian. In contrast with those two, however, and similar to Western European languages such as German or French, Polish uses the English/Latin alphabet with a few customizations.
Original Polish words never contain Q, V or X, although we keep them for Latin and other borrowed words. In exchange for those three, however, Polish adds nine additional diacritics using Latin characters as their base, all in relatively common use: ą, ć, ę, ł, ń, ó, ś, ź, ż.
Starting in the early 20th century, typewriters needed to accommodate the extra 9 letters. If you compare an American typewriter with a Polish one, and look at the right side of the keyboard, you can see two of the diacritics — ł and ż — promoted to separate keys, and the rest sharing keys with digits. To find room for the extra letters, typewriters needed to dispense with some punctuation, most notably semicolons and parentheses.
Ingredient 2/4: Communism
For someone interested in the early personal computing in the 1980s, Communism in Poland meant two things:
- Not a lot of disposable income,
- Forbidden commercial importing of computers from the West (individual importing was still possible, assuming you had enough foreign currency and some means of acquiring it).
Technology was delayed on that side of the Iron Curtain; most computers were imported from the West. Prohibited commercial importing meant that for the longest time there was no commercial entity that could prepare computers for use in Poland. Foreign computers arrived with original instructions, untranslated software, and American keyboards.
While France, Germany, and other countries got their early PCs with customized keyboards whose layouts mirrored closely the typewriters that came before, in Poland, we had to find another way of inputting the extra 9 diacritics unique to our language.
We could not modify the hardware, but we could still try to find a clever solution. There are two modifier keys — Ctrl and Alt. Ctrl was already used as a common shortcut key, but Alt was relatively uncommon. And thus, a de facto standard was born, assigning our diacritics to their Latin counterparts using the Right Alt (AltGr) key (e.g., Alt + S for ś).
People started calling this the "programmer's layout". The new layout was an ergonomic nightmare, but it was easy to understand and did not require any expensive hardware modifications. It stuck. The setup was so successful that practically no one would switch to proper typist's keyboards when they appeared a decade later.
Ingredient 3/4: Old habits dying hard
Autosaving, common today, needed to wait for the right moment. Especially in the 1980s and 1990s, saving your document was lengthy, would slowly wear out whatever medium you were using, and sometimes occupy CPU so intensely it couldn’t be used for anything else.
Saving by hand was a habit you needed to learn for your own good. We all learned to press Ctrl + S whenever we paused for breath. Ctrl + S became a keystroke buried in people’s motor memories.
Then that habit turned on them. If you write in any web-based editor, the default thing that happens after pressing the save key combination is a browser window giving you a completely useless option to save the current website’s HTML code.
To make the save dialog go away, Medium added a little bit of code to our editor:
if ((e.metaKey || e.ctrlKey) && e.keyCode === goog.events.KeyCodes.S) {
this._editors.save();
e.preventDefault();
}
It translates to: if S happens to be pressed with Command (on Mac) or Ctrl (on Windows/Linux), prompt our editor to save what it’s doing, and prevent the annoying browser save dialog from appearing.
This felt like the right thing to do. But something didn’t compute: Medium is blocking Ctrl + S, but you get to ś by keying in Alt + S. For these two worlds to collide, we need just one more ingredient.
Ingredient 4/4: Microsoft Windows
Both Windows 3.x and 95 had terrific keyboard support. Most of Microsoft Windows UI could be turned into a sequence of keyboard presses using the Alt key combined with underlined letters.
However, in countries using non-US keyboards where the Right Alt (AltGr) key is used for regional characters, Windows had to avoid conflicting with the standard menu shortcuts. To solve this, Windows internally emulates the AltGr key as Ctrl + Alt.
When a Polish user presses AltGr + S to type ś, Windows sends a keystroke combination of Ctrl + Alt + S to the browser.
Our JavaScript code checked if e.ctrlKey was true and the key was S. Because Windows emulated Ctrl during the AltGr press, e.ctrlKey evaluated to true. The editor intercepted the keystroke, triggered the save function, and called e.preventDefault(), which stopped the letter ś from being typed!
We fixed this by ensuring the Alt key is not pressed when triggering the save shortcut:
if ((e.metaKey || (e.ctrlKey && !e.altKey)) && e.keyCode === goog.events.KeyCodes.S) {
this._editors.save();
e.preventDefault();
}
With this simple fix, the three-decade-old conflict was resolved, and Polish writers can now freely type their "ś" on Medium.
Source: Hacker News












