Why do Macs ask you to press random keys when connecting a new keyboard?

zdw 18 points 23 comments April 06, 2026
unsung.aresluna.org · View on Hacker News

Discussion Highlights (12 comments)

alsetmusic

Mapping to ensure that it has the correct layout applied.

altairprime

See also the layout identifier manual-elsif/elsif/elsif workflow here, last updated November 2023: https://support.apple.com/en-us/102743

throwaway27448

Random ≠ arbitrary

emeraldd

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.

srean

Ah! Thanks for the stimulation. That's an interesting problem that I had not thought of before. In fact a few related problems. What's the minimum set of requested key presses that will uniquely identify a keyboard layout from a set of known types. Given a budget of k key strokes what's the most informative subset that will reduce the ambiguity about layout. Given the measurement from the requested key strokes find the posterior over the set of known keyboard layouts. 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.

dirasieb

they don't ask you to press random keys

ginko

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.

weinzierl

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?

vinni2

Why does it sometimes ask when connecting a HDMI projector?

tomasphan

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.

daft_pink

Thanks I’m always worried. I do the wrong thing when that thing pops up for my mouse.

ch_123

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: https://www.clickykeyboards.com/wp-content/uploads/2023/03/I... ). 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.

Semantic search powered by Rivestack pgvector
3,752 stories · 35,056 chunks indexed