[HN Gopher] Why do Macs ask you to press random keys when connec...
       ___________________________________________________________________
        
       Why do Macs ask you to press random keys when connecting a new
       keyboard?
        
       Author : zdw
       Score  : 25 points
       Date   : 2026-04-06 16:40 UTC (2 days ago)
        
 (HTM) web link (unsung.aresluna.org)
 (TXT) w3m dump (unsung.aresluna.org)
        
       | alsetmusic wrote:
       | Mapping to ensure that it has the correct layout applied.
        
         | Our_Benefactors wrote:
         | Yes, but this doesn't answer why I only have to do this on Mac
         | and not windows/linux, where I have literally never run into an
         | issue as a result of not doing it.
        
           | QuercusMax wrote:
           | I assume for some nonzero percentage of folks it _doesn 't_
           | work right and they have to manually go and set their
           | keyboard layout.
           | 
           | Of course, when you're setting up your OS initially, it will
           | ask you questions about language and keyboard layout. I
           | suspect most people don't switch keyboards after install, and
           | of those who do, the most common case is another keyboard
           | with a compatible layout.
        
           | HPsquared wrote:
           | I assume you have a standard US keyboard.
        
           | jasonjayr wrote:
           | Most non-Apple branded keyboards are _NOT_ tested with mac;
           | so it doesn 't trust any electronic tags/labels, nor does it
           | keep a database. Easiest thing to make it work 100% without
           | asking the user to identify their layout, is to press random
           | keys so the mac knows where things are mapped.
        
           | masfuerte wrote:
           | Windows and Linux both ask for your language and locale
           | during setup and default to the typical matching keyboard.
           | I'm nearly sure Debian also asks you to confirm the keyboard
           | it picked, but it's always the right one so I just hit enter.
        
           | thebruce87m wrote:
           | Do you live in a country where the default always maps
           | correctly? My UK keyboards will always have specific keys
           | wrong.
        
           | dlcarrier wrote:
           | If you're using a US English keyboard layout, it's the
           | default and you won't have to deal with changing it.
           | 
           | The most likely reason it would be a problem then would be
           | that some Raspberry Pi images have defaulted to British
           | English keyboard layouts. Otherwise you may be sailing
           | through life unburdened by what can be a major pain to anyone
           | anywhere else in the world, like a resident of Arizona
           | wondering why the rest of the world keeps messing with their
           | clocks.
        
       | altairprime wrote:
       | See also the layout identifier manual-elsif/elsif/elsif workflow
       | here, last updated November 2023:
       | 
       | https://support.apple.com/en-us/102743
        
       | throwaway27448 wrote:
       | Random [?] arbitrary
        
         | chimeracoder wrote:
         | > Random [?] arbitrary
         | 
         | Sure, though if you're looking to be pedantic, the keys they're
         | asking you to press are neither random _nor_ arbitrary
        
           | throwaway27448 wrote:
           | How are they not arbitrary? Apple tells you a specific key to
           | press, which is a choice. It is by definition arbitrary.
           | 
           | Edit: perhaps you're making the case that the user doesn't
           | choose which key. This is true--but the important point is
           | that one of the two parties _did_ choose the specific key to
           | press.
           | 
           | Edit2: For those downvoting, perhaps you could articulate
           | why.
        
             | lgas wrote:
             | Arbitrary and random are basically the same in this
             | context. The person you're replying to is pointing out they
             | are specific keys for specific reasons because those
             | specific keys can be used to figure out which kind of
             | keyboard it is, they are not random or arbitrary, they are
             | chosen with a specific reason in mind. If they were really
             | chosen arbitrarily, they would not be able to accomplish
             | the goal.
        
             | toast0 wrote:
             | My impression is that Apple's choice of keys was
             | constrained.
             | 
             | The American Heritage(r) Dictionary of the English
             | Language, 5th Edition defines arbitrary as
             | 
             | > Determined by chance, whim, or impulse, and not by
             | necessity, reason, or principle.
             | 
             | But the choices seem to be based on reason or principle.
        
             | dylan604 wrote:
             | they are not random requests. they are keys known to have
             | different locations depending on the locale. by seeing what
             | the values sent when the requested key is pressed, they
             | know how to map the inputs from the keyboard.
             | 
             | that definitely does not sound arbitrary to me.
        
       | emeraldd wrote:
       | 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 wrote:
       | 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 wrote:
       | they don't ask you to press random keys
        
       | ginko wrote:
       | 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 wrote:
       | 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?
        
         | avidiax wrote:
         | That would break credit card readers, barcode scanners, and
         | special purpose keyboards (like video workstations).
         | 
         | 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.
         | 
         | Still seems like it would be difficult for the average user.
        
       | vinni2 wrote:
       | Why does it sometimes ask when connecting a HDMI projector?
        
         | leejoramo wrote:
         | Many projectors include remotes that allow you to control a
         | slide presentation. These remotes send the default keystrokes
         | that Microsoft PowerPoint knows (and which other presentation
         | software copied) So when you connect a projector the OS often
         | sees a keyboard and mouse. This triggers macOS's keyboard
         | recognition tool. Old VGA projectors had separate
         | keyboard/mouse ports. I assume HDMI has a USB channel?
        
       | tomasphan wrote:
       | 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 wrote:
       | Thanks I'm always worried. I do the wrong thing when that thing
       | pops up for my mouse.
        
       | ch_123 wrote:
       | 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.
        
       | hennell wrote:
       | 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.
        
       ___________________________________________________________________
       (page generated 2026-04-08 23:00 UTC)