Ah! Thanks for the stimulation. That's an interesting problem that I had not thought of before. In fact a few related problems.<p>What's the minimum set of requested key presses that will uniquely identify a keyboard layout from a set of known types.<p>Given a budget of k key strokes what's the most informative subset that will reduce the ambiguity about layout.<p>Given the measurement from the requested key strokes find the posterior over the set of known keyboard layouts.<p>Given that the user is typing some free form text in his language how soon can one nail the layout when the user's language, the layout and the text are unknown. Will make a good practice exercise for hobbyist codebreaking.
I guess the moment has passed by now but I wish there were a USB HID protocol for keyboards to identify their layout, or even better yet make the keyboard protocol layout agnostic so that keyboards send the high-level unicode character / modifier instead of a physical key code.
In addition to the three physical keyboard layouts in this post, there's a fourth one which has an extra key on both the right and the left side of the keyboard. An example is the Brazilian Portuguese layout Model M (pic: <a href="https://www.clickykeyboards.com/wp-content/uploads/2023/03/IMG_1176.jpeg" rel="nofollow">https://www.clickykeyboards.com/wp-content/uploads/2023/03/I...</a>). The Apple test would be able to identify it, although I've never tried it in practice. I don't think the modern Brazilian Apple keyboard uses this arrangement.
> there's a fourth one which has an extra key on both the right and the left side of the keyboard. An example is the Brazilian Portuguese layout Model M (pic: ...)<p>That's the ABNT2 keyboard layout, which is the keyboard layout used here in Brazil. AFAIK, it's the only common keyboard layout with that characteristic.
Mapping to ensure that it has the correct layout applied.
I think every OS should ask you to press a freshly generated sequence of keys when connecting a keyboard to prevent BadUSB attacks. Does any system do this?
That would break credit card readers, barcode scanners, and special purpose keyboards (like video workstations).<p>I suppose you could rely on a binary code, where the user is instructed to press any two keys to repeat the code, or if there is only one key (or it's a barcode scanner), to enter the same input multiple times, separated by long and short pauses.<p>Still seems like it would be difficult for the average user.
Honestly, the mac approach makes much more sense from an ease of use perspective for non-experts. On other platforms, you have to know the layout to choose and hope things work until you do or have a second keyboard that's close enough tl the default to get by. On Mac, it just figures it out based on the information you tell it when the keyboard is connected. Much less error prone in the majority of cases.
Random ≠ arbitrary
I feel like a UK windows keyboard and a Mac has some oddities like this. I've got a zsa split keyboard and still haven't worked out how to have punctuation the same in Mac and windows. @ and " are always flipped and I had to add additional buttons to ensure I have a | and ~ keys because who knows where the Mac thinks they are.
See also the layout identifier manual-elsif/elsif/elsif workflow here, last updated November 2023:<p><a href="https://support.apple.com/en-us/102743" rel="nofollow">https://support.apple.com/en-us/102743</a>
Thanks I’m always worried. I do the wrong thing when that thing pops up for my mouse.
Why does it sometimes ask when connecting a HDMI projector?
Why do American keyboards have that horizontal enter key?<p>As a Brit, with plenty of notionally British keyboards to choose from (with £ signs for the price and the '3' key), too often there is this wrong-shaped horizontal enter key. What is the thinking behind that?<p>As for the article, mystery key pressing games might be incredibly clever in the parallel universe of the Apple cult, and even quite fun, particularly if you press the wrong keys deliberately, but I prefer the Ubuntu way, where you just have the keyboard for your locale selected, with the option to change it, if you really want to.
they don't ask you to press random keys
Apple has to make it annoying to use a non-Apple device with your Apple device. That sort of friction probably nets them 2% in keyboard sales per year.