The curious case of the disappearing Polish S
-
https://medium.engineering/the-curious-case-of-disappearing-polish-s-fa398313d4df#.l98z5644w
TL;DR
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.
[...]
Putting all of this together, the reason for the bug becomes obvious:
- Through historical circumstance, people in Poland use Right Alt+S to type in Ĺ.
- Because of an obscure technical decision, Right Alt+S is mapped internally to Ctrl+Alt+S.
- Through habit, people might occasionally want to press Ctrl+S to save a document.
- 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 I figured it out, the patch was trivial. Instead of blindly blocking Ctrl+S, we could block Ctrl+S only if Alt key was not pressed.
-
This kind of thing appears roughly a million times all over the web. The underlying problem is that webdevs go out of their way to reimplement standard input handling, buttons, etc. without having any clue about how to do it right and the many edge cases to handle.
Mostly unrelated example but happened to me just yesterday:
I was trying to order a picture collage at an online service. There's a designer where you can upload pictures and place them on the canvas, a bit like a trivial PowerPoint or vector graphics program. When you clicked the picture, you could use the arrow keys to move it around as expected. But theres also a size / position tab where you can enter exact values. Now the thing is, when I used the arrow keys inside this input element (left/right to move the cursor, or up/down to change the value of the spinbox-like thing) it did the expected changes to the input field, but also moved the image around as if I still had that selected.Why? Because they have no fucking clue what they're doing and so basically two controls have keyboard focus at the same time. That's something that just doesn't happen when using existing controls, unless you go out of your way to intentionally do it.
-
@topspin said in The curious case of the disappearing Polish S:
Now the thing is, when I used the arrow keys inside this input element (left/right to move the cursor, or up/down to change the value of the spinbox-like thing) it did the expected changes to the input field, but also moved the image around as if I still had that selected.
Bonus fun if the new position then updated the field value and buggered up the caret anyway.
That's something that just doesn't happen when using existing controls
Webpage. Existing controls.
Iâd say the sins of the Medium story are:
- Only affirming the involved modifiers and not checking the state of all of them
- Lack of API for intercepting save action, or non-use of it if so. Thereâs no guarantee that saving is triggered by ctrl+S, and as long as itâs possible to intercept arbitrary keyboard shortcuts, it might as well be possible to intercept their intended actions directly and explicitly.
-
@topspin said in The curious case of the disappearing Polish S:
This kind of thing appears roughly a million times all over the web.
Nope. The very same thing happens (and the very same fix applies) in Windows desktop äpps. is Windows, with its obscure technical decisions.
-
@kazitor said in The curious case of the disappearing Polish S:
- Lack of API for intercepting save action, or non-use of it if so. Thereâs no guarantee that saving is triggered by ctrl+S, and as long as itâs possible to intercept arbitrary keyboard shortcuts, it might as well be possible to intercept their intended actions directly and explicitly.
i'd argue the attempt to block the user from saving at all is a sin, right up there with disabling the right click menu, highlighting, copying, etc.... none of that is going to stop someone who is determined but it is gonna piss them off something fierce, and there are legitimate reasons why someone would want to save a local copy of a webpage, or right click, or highlight and copy text...
>_>
<_<
-
@topspin said in The curious case of the disappearing Polish S:
webdevs ... without having any clue
But you repeat yourself.
-
An interesting story, and the writing of the story required research by involved people as well. One could easily imagine them fixing the problem without doing the research to find out the historical causes of the problem.
-
@accalia They do mention that the user can still save the web page through the browser menus, if they want; and that the only reason they override Ctrl+S is to combat finger memory of people trying to save the text they've written. I think it's sensible in this particular case.
-
@Zecc said in The curious case of the disappearing Polish S:
to combat finger memory of people trying to save the text they've written. I think it's sensible in this particular case.
What would be even more sensible would be to make CTRL+S actually save the text that was written.
-
@ixvedeusi From the article:
-
@Zecc said in The curious case of the disappearing Polish S:
@ixvedeusi From the article:
And it's still wrong, since they should have learned to check for all the not-modifier-keys in their key combinations.
-
@Parody You mustn't just blindly check the modifier state either, otherwise you treat Caps Lock vs Shift in ways that violate user expectations.
-
@dkf not for shortcuts. Caps Lock + Tab is very different from Shift + Tab.
-
@Gustav said in The curious case of the disappearing Polish S:
@dkf not for shortcuts. Caps Lock + Tab is very different from Shift + Tab.
Yes, but Caps+Shift+Tab is the same as Shift+Tab.
-
@dkf because Caps Lock is not a modifier. It won't be present when you check for modifiers state.
-
@Gustav said in The curious case of the disappearing Polish S:
@dkf because Caps Lock is not a modifier. It won't be present when you check for modifiers state.
Alas, you are wrong. It is... and it is the modifier bit you need to ignore. Modifiers are a goddamn mess.
-
@dkf Does this depend on which API you are using and/or whether the user's keyboard is using n-key-rollover?
-
-
@PleegWat said in The curious case of the disappearing Polish S:
@dkf Does this depend on which API you are using and/or whether the user's keyboard is using n-key-rollover?
Not the faintest clue. I know I've seen it in the wild.
And @Gustav, just because they aren't modifiers doesn't mean that they don't show up in the modifier bits. Welcome to the hell that is the ugly end of GUI event details. (It gets worse. Input Methods are just the most ugly set of hacks ever, and getting a US programmer to understand them at all is nearly impossible...)
-
@dkf said in The curious case of the disappearing Polish S:
And @Gustav, just because they aren't modifiers doesn't mean that they don't show up in the modifier bits.
Same with the letter R. Or the Page Down key. As always, consult reference manual for your particular brand of insanity.
But in the APIs I'm familiar with, checking the whole modifiers field at once is the right way to do, as it avoids the exact bug described in OP. The root cause was that they checked for the Ctrl modifier in separation from the other ones, just like you suggest.
-
@dkf said in The curious case of the disappearing Polish S:
@Gustav said in The curious case of the disappearing Polish S:
@dkf not for shortcuts. Caps Lock + Tab is very different from Shift + Tab.
Yes, but Caps+Shift+Tab is the same as Shift+Tab.
On my Windows machines, that always holds true.
I manipulated shit lock to be shift only with a registry häck.
OTOH, a colleague once told me that her husband used a screwdriver to get physically rid of the shit lock key.
-
@BernieTheBernie when I was teenager, I ripped off left Windows key after I accidentally minimized a game one time too many.
-
@dkf said in The curious case of the disappearing Polish S:
@Gustav said in The curious case of the disappearing Polish S:
@dkf because Caps Lock is not a modifier. It won't be present when you check for modifiers state.
Alas, you are wrong. It is...
Thereâs no
capsKey
orcapsLockKey
property. Only alt, ctrl, meta, and shift.As far as I know the only way to even check whether caps lock is held down is to set something on keydown and unset it on keyup â JS simply doesnât report the state of any keys beyond those four and whatever triggered the event.
-
@kazitor said in The curious case of the disappearing Polish S:
@dkf said in The curious case of the disappearing Polish S:
@Gustav said in The curious case of the disappearing Polish S:
@dkf because Caps Lock is not a modifier. It won't be present when you check for modifiers state.
Alas, you are wrong. It is...
Thereâs no
capsKey
orcapsLockKey
property. Only alt, ctrl, meta, and shift.KeyboardEvent.getModifierState() lets you check extended modifiers like AltGr and the toggle state for Caps, Num, and Scroll Lock.
For a keyboard shortcut Caps Lock shouldn't matter, but the specific combination of Ctrl/Alt/Shift/Meta does and they should be restricting their checking to those combinations.
They're also not reflecting the differences between the underlying platforms. Meta-S (Windows + S) shouldn't save on Windows assuming it gets to the browser (the OS usually hijacks those), Control-NoShift-S shouldn't save on Mac OS, and I expect one of those shouldn't save on most of the various Unix-like platforms. Maybe both.
As far as I know the only way to even check whether caps lock is held down is to set something on keydown and unset it on keyup â JS simply doesnât report the state of any keys beyond those four and whatever triggered the event.
That's KeyboardEvent.key == "CapsLock", it seems. (I'm not a web input programming expert but I play one on Google.)
-
@Parody said in The curious case of the disappearing Polish S:
Meta-S (Windows + S) shouldn't save on Windows
@Parody said in The curious case of the disappearing Polish S:
Control-NoShift-S shouldn't save on Mac OS
the one true way to save:
[Esc] (to exit to command mode from input mode if input mode was previously entered)
then
:w[Return]
or
:wq[Return]
depending on if you wish to quit after saving or return to command mode.
-
@accalia You know about ZZ?
-
@dkf said in The curious case of the disappearing Polish S:
@accalia You know about ZZ?
if you wish a conditional save to not update metadata if there were no code changes i guess
:x
orZZ
work.you're welcome to use those if you wish too. the nice thiong about using a proper programable editor is you can do things in so many good and awesome ways.
i'll stick to the old tried and true
:w
since I more often than not wish to trigger a directory change for a watcher to pick up the change and dynamically recompile or something and the change i made might not be literally in the file and in the case where i don't need the metadata to change from a forced write it never seems to hurt.
-
@accalia I tend to use
^O
for saving when doing editing on the Unix-likes. Because I'm a simple man with simple needs.
-
@accalia said in The curious case of the disappearing Polish S:
the one true way to save:
[Esc] (to exit to command mode from input mode if input mode was previously entered)
then
:w[Return]
or
:wq[Return]
depending on if you wish to quit after saving or return to command mode.One of my early Internet accounts was on a service that had grown up from a BBS (which was still running at the time) and provided shell access as well as (if you were in their area) being an ISP.
Part of the (sparse) documentation was a page named "The most useful things we can tell you." It included sections like "This what
emacs
looks like and here's how you get out of it.", "This is whatvi
looks like and here's how you get out of it.", and "Those first two are why we recommend you usepico
."
-
-
What nonsense is this? Kurwa is the only word in the Polish language and that doesnât need an S.
-
@Parody said in The curious case of the disappearing Polish S:
One of my early Internet accounts was on a service that had grown up from a BBS (which was still running at the time) and provided shell access as well as (if you were in their area) being an ISP.
Part of the (sparse) documentation was a page named "The most useful things we can tell you." It included sections like "This what
emacs
looks like and here's how you get out of it.", "This is whatvi
looks like and here's how you get out of it.", and "Those first two are why we recommend you usepico
."Vi, in particular, had a big advantage on slow links of the time: the advanced movement commands allow you to blindly key in the move to position and change of word or whatever and the new text without waiting five seconds for the screen update to come back in between.
-
@Bulb said in The curious case of the disappearing Polish S:
@Parody said in The curious case of the disappearing Polish S:
One of my early Internet accounts was on a service that had grown up from a BBS (which was still running at the time) and provided shell access as well as (if you were in their area) being an ISP.
Part of the (sparse) documentation was a page named "The most useful things we can tell you." It included sections like "This what
emacs
looks like and here's how you get out of it.", "This is whatvi
looks like and here's how you get out of it.", and "Those first two are why we recommend you usepico
."Vi, in particular, had a big advantage on slow links of the time: the advanced movement commands allow you to blindly key in the move to position and change of word or whatever and the new text without waiting five seconds for the screen update to come back in between.
5t[space]
is also just faster than holding down the right arrow until the cursor is on the 5th space to the right, or moving your hand off the keyboard to the mouse.
This also extends to usinghjkl
instead of the arrow keys (though ViM supports both).
-
@Bulb that is an era filled with competence the likes of which we shall never see again.
-
@Arantor It was an era filled with slow communication links, the likes of which we hope to never see again.
-
@Arantor said in The curious case of the disappearing Polish S:
@Bulb that is an era filled with competence the likes of which we shall never see again.
And also unnecessarily steep learning curves making even the simplest tasks require a training course.
I still don't know how to even type in vim, and at this point I hope I'll never have to learn. (Unfortunately, I know how to use emacs, rudimentarily.)
-
@PleegWat said in The curious case of the disappearing Polish S:
mouse
Mouse? I don't want no mice near my glass teletype terminal, they'd chew through the serial line.
-
@Bulb said in The curious case of the disappearing Polish S:
@PleegWat said in The curious case of the disappearing Polish S:
mouse
Mouse? I don't want no mice near my glass teletype terminal, they'd chew through the serial line.
I've got a cat who may be able to help with those mice. That or he'll chew through the keyboard cord. 50/50 really.
-
@PleegWat said in The curious case of the disappearing Polish S:
I've got a cat who may be able to help with those mice.
Do you mean this one?
Filed under: The thread is .
-
@remi said in The curious case of the disappearing Polish S:
Filed under: The thread is
every thread I participate in, which is nearly all of them.
-
@HardwareGeek but without looking it up, can you tell the name of that particular cat?
Filed under: random internet trivia.
-
@remi No, I have no idea.
-
@HardwareGeek I could tell you, but then I'd
have to kill youspoil it for everyone else.Oh well.
:CueCatETA: it even has its Wiki page. The idea wasn't totally stupid, in fact it's more or less a QR code with dedicated hardware. Probably just 20 years too early and with dedicated hardware.
Don't ask me why I remember.
-
@remi I even remember where I read about it (at least 5 years after the fact, though). Here: https://www.joelonsoftware.com/2000/09/12/wasting-money-on-cats/
-
@dkf said in The curious case of the disappearing Polish S:
@Arantor It was an era filled with slow communication links, the likes of which we hope to never see again.
I have AT&T uVerse. Not sure about that...
-
@Bulb this is the source that I also remember, although I have a vague memory of reading about it in a dead-tree magazine (in French!), in the coffee room of a lab at university. But, like in any communal space, magazines were left over for years after their publication date, so I can't say how long after the fact it was.
-
@topspin said in The curious case of the disappearing Polish S:
@Arantor said in The curious case of the disappearing Polish S:
@Bulb that is an era filled with competence the likes of which we shall never see again.
And also unnecessarily steep learning curves making even the simplest tasks require a training course.
I still don't know how to even type in vim, and at this point I hope I'll never have to learn. (Unfortunately, I know how to use emacs, rudimentarily.)I learned vim because everything else (except for Emacs, which I found too bloated) was just shit. These days I'd say if you don't care about free software and don't intend to do any sysadminning, fine, you'll be happy with SublimeText, but that's just the last 10 years. And still, the pain I see colleagues having when despite their intentions to just be a developer or consultant, they have to ssh into a client's machine and fix stuff with nano âŚ
-
@LaoC said in The curious case of the disappearing Polish S:
you'll be happy with SublimeText,
Confirmed.
-
@remi said in The curious case of the disappearing Polish S:
@PleegWat said in The curious case of the disappearing Polish S:
I've got a cat who may be able to help with those mice.
Do you mean this one?
Ahh, the free book scanner! Thanks to this device I can look up which storage box has my paperback copy of The Hobbit, find where it's placed in the pile of storage boxes, and go
download a copypurchase a copy on Amazon for my Kindle so I can read it again.