Meta Keys Harmful

The curious case of the disappearing Polish S. One keyboard bug three decades in the making. medium

quote

Medium was overriding whatever default action happened when you pressed Ctrl+S, thinking it’s just a browser save dialog it was canceling… and never realizing it could be something else: a letter Ś.

And so, typing Ś became impossible.

Once figuring it out, the patch was trivial. Instead of blindly blocking Ctrl+S, we could block Ctrl+S only if Alt key was not pressed.

if ((e.metaKey || e.ctrlKey && !e.altKey)) && e.keyCode === goog.events.KeyCodes.S) { this._editors.save() e.preventDefault()}

The few lines of code above might be, to me, one of the most curious in Medium’s codebase, the result of an arbitrary set of circumstances… today copiously commented so that people coming after me understand the one opaque conditional statement.

.

We make frequent use of these event properties in wiki with little force for consistency. Its going to hurt us eventually as it hurt this engineer who happened to know the long history of adaptation in keyboard input.

console.log meta: e.metaKey alt: e.altKey ctrl: e.ctrlKey shift: e.shiftKey