15 comments

  • srean2 days ago
    Ah! Thanks for the stimulation. That&#x27;s an interesting problem that I had not thought of before. In fact a few related problems.<p>What&#x27;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&#x27;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&#x27;s language, the layout and the text are unknown. Will make a good practice exercise for hobbyist codebreaking.
  • ginko2 days ago
    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 &#x2F; modifier instead of a physical key code.
  • ch_1232 days ago
    In addition to the three physical keyboard layouts in this post, there&#x27;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:&#x2F;&#x2F;www.clickykeyboards.com&#x2F;wp-content&#x2F;uploads&#x2F;2023&#x2F;03&#x2F;IMG_1176.jpeg" rel="nofollow">https:&#x2F;&#x2F;www.clickykeyboards.com&#x2F;wp-content&#x2F;uploads&#x2F;2023&#x2F;03&#x2F;I...</a>). The Apple test would be able to identify it, although I&#x27;ve never tried it in practice. I don&#x27;t think the modern Brazilian Apple keyboard uses this arrangement.
    • cesarb18 minutes ago
      &gt; there&#x27;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&#x27;s the ABNT2 keyboard layout, which is the keyboard layout used here in Brazil. AFAIK, it&#x27;s the only common keyboard layout with that characteristic.
  • alsetmusic2 days ago
    Mapping to ensure that it has the correct layout applied.
    • Our_Benefactors2 days ago
      Yes, but this doesn’t answer why I only have to do this on Mac and not windows&#x2F;linux, where I have literally never run into an issue as a result of not doing it.
      • dlcarrier2 days ago
        If you&#x27;re using a US English keyboard layout, it&#x27;s the default and you won&#x27;t have to deal with changing it.<p>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.
      • masfuerte2 days ago
        Windows and Linux both ask for your language and locale during setup and default to the typical matching keyboard. I&#x27;m nearly sure Debian also asks you to confirm the keyboard it picked, but it&#x27;s always the right one so I just hit enter.
      • jasonjayr2 days ago
        Most non-Apple branded keyboards are <i>NOT</i> tested with mac; so it doesn&#x27;t trust any electronic tags&#x2F;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.
      • HPsquared2 days ago
        I assume you have a standard US keyboard.
      • thebruce87m2 days ago
        Do you live in a country where the default always maps correctly? My UK keyboards will always have specific keys wrong.
      • QuercusMax2 days ago
        I assume for some nonzero percentage of folks it <i>doesn&#x27;t</i> work right and they have to manually go and set their keyboard layout.<p>Of course, when you&#x27;re setting up your OS initially, it will ask you questions about language and keyboard layout. I suspect most people don&#x27;t switch keyboards after install, and of those who do, the most common case is another keyboard with a compatible layout.
  • weinzierl2 days ago
    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?
    • avidiax2 days ago
      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&#x27;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.
      • dylan60448 minutes ago
        Having those devices ID themselves to the OS as a keyboard sounds like an idea where someone said &quot;it&#x27;ll be fine&quot; rather than doing something more specific. sure, hindsight is 20&#x2F;20 and all.
        • MBCook20 minutes ago
          There must be a way to tell them apart in the USB protocol because I’ve never gotten the keyboard prompt on my Mac when I plug one of those in.
  • emeraldd2 days ago
    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&#x27;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.
  • throwaway274482 days ago
    Random ≠ arbitrary
    • chimeracoder2 days ago
      &gt; Random ≠ arbitrary<p>Sure, though if you&#x27;re looking to be pedantic, the keys they&#x27;re asking you to press are neither random <i>nor</i> arbitrary
      • throwaway274482 days ago
        How are they not arbitrary? Apple tells you a specific key to press, which is a choice. It is by definition arbitrary.<p>Edit: perhaps you&#x27;re making the case that the user doesn&#x27;t choose which key. This is true—but the important point is that one of the two parties <i>did</i> choose the specific key to press.<p>Edit2: For those downvoting, perhaps you could articulate why.
        • dylan60449 minutes ago
          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.<p>that definitely does not sound arbitrary to me.
        • toast053 minutes ago
          My impression is that Apple&#x27;s choice of keys was constrained.<p>The American Heritage® Dictionary of the English Language, 5th Edition defines arbitrary as<p>&gt; Determined by chance, whim, or impulse, and not by necessity, reason, or principle.<p>But the choices seem to be based on reason or principle.
        • lgas1 hour ago
          Arbitrary and random are basically the same in this context. The person you&#x27;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.
    • naikrovek47 minutes ago
      Random != unexpected
  • hennell1 hour ago
    I feel like a UK windows keyboard and a Mac has some oddities like this. I&#x27;ve got a zsa split keyboard and still haven&#x27;t worked out how to have punctuation the same in Mac and windows. @ and &quot; 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.
  • altairprime2 days ago
    See also the layout identifier manual-elsif&#x2F;elsif&#x2F;elsif workflow here, last updated November 2023:<p><a href="https:&#x2F;&#x2F;support.apple.com&#x2F;en-us&#x2F;102743" rel="nofollow">https:&#x2F;&#x2F;support.apple.com&#x2F;en-us&#x2F;102743</a>
  • daft_pink2 days ago
    Thanks I’m always worried. I do the wrong thing when that thing pops up for my mouse.
  • vinni22 days ago
    Why does it sometimes ask when connecting a HDMI projector?
    • leejoramo2 days ago
      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&#x2F;mouse ports. I assume HDMI has a USB channel?
      • cesarb12 minutes ago
        &gt; I assume HDMI has a USB channel?<p>No, it doesn&#x27;t, it only has I2C (for display identification and control, same as VGA and DVI) and CEC (for remote control).
  • Theodores17 minutes ago
    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 &#x27;3&#x27; 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.
  • dirasieb2 days ago
    they don&#x27;t ask you to press random keys
  • tomasphan2 days ago
    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.