Typing Brackets and Symbols on Any Layout
The opening brace is Shift with a key beside P on US ANSI, AltGr with 7 on the German T1 layout, and AltGr with 4 on French AZERTY. The characters that source code depends on are the least stable part of any keyboard, and a symbol that takes one hand in one country takes two in the next.
The characters that matter
A short list covers most of what programming languages, shells and configuration formats need beyond letters and digits: the three kinds of bracket, the backslash, the vertical bar, the tilde, the at sign, the caret, and the hash. Curly braces and the vertical bar cause the most trouble, because they are the ones that European layouts hide behind AltGr.
US ANSI positions
On the US layout everything sits unshifted or behind Shift, and nothing needs AltGr at all.
- Square brackets are the two keys right of P; braces are Shift with the same keys.
- Backslash is the key above Enter; the vertical bar is Shift with it.
- Semicolon and apostrophe are on the home row right hand side; colon and double quote are their shifted forms.
- Angle brackets are Shift with comma and full stop.
- Tilde and backtick share the key left of the digit 1.
That arrangement is the reason so much programming convention assumes a US board. Every symbol is one modifier away, and the third level of the keyboard is unused.
German QWERTZ and the third level
The German T1 layout keeps the digit row for punctuation that German needs, so the code symbols move to AltGr.
- Braces and square brackets run across the digits: AltGr with 7, 8, 9 and 0 gives the opening brace, the opening bracket, the closing bracket and the closing brace.
- Backslash is AltGr with the eszett key, right of the zero.
- The vertical bar is AltGr with the key beside the left Shift, the extra key that exists only on ISO boards.
- The at sign is AltGr with Q, and the tilde is AltGr with the plus key.
Two consequences follow. The bar is unreachable on a board built to the ANSI shape, because the physical key it lives on is not there, which is one of the practical differences between ISO and ANSI. And the braces sit under the weaker fingers of the left hand while AltGr is held by the right thumb, which is why typing code feels heavier on a German board than the character count suggests.
French AZERTY
AZERTY moves the digits themselves behind Shift, and puts the code symbols on AltGr in the same row.
- AltGr with 4 gives the opening brace, AltGr with 5 the opening square bracket, AltGr with 6 the vertical bar.
- AltGr with 8 gives the backslash, and AltGr with 0 gives the at sign.
- The semicolon is unshifted on the bottom row, and the full stop needs Shift, which reverses the habit of every other layout mentioned here.
That last reversal catches people out more than the braces do, because a misplaced full stop is a valid character in most languages and produces an error somewhere else entirely.
The US International compromise
Many programmers working in a language with accented letters settle on a third option: the US International layout. It keeps every symbol where the US layout puts it, so braces, brackets and the vertical bar need Shift and nothing else, and it adds accented characters through AltGr combinations and dead keys instead of rearranging the board.
The cost is one specific annoyance. On US International the apostrophe and the double quote become dead keys, so typing an apostrophe followed by a vowel produces an accented letter rather than the two characters you wanted, and a space is needed after the quote to make it appear on its own. Whether that trade is worth it depends on how much of your day is code and how much is prose in a language with accents.
Why a keyboard test must separate position from character
A browser reports two different things for every press. KeyboardEvent.code names the physical key by its position on a US reference board, so the key beside P is always BracketLeft no matter which layout is active. KeyboardEvent.key names the character that key actually produced, which on a German layout might be ü.
A test that only reads one of those two gets these keys wrong. Read the position alone and the diagram claims a German user pressed a bracket. Read the character alone and any key that produces nothing on its own, including the dead keys used for accents, looks broken. Our keyboard test keeps both, which is what lets it draw five layouts correctly instead of relabelling one.
If you want to feel how much punctuation weighs before touching code, three passages rehearse it without a single line of source. The eleventh edition of the Encyclopaedia Britannica, printed in 1911, lists old English and Scottish standards in 315 characters, with a year in brackets and a semicolon after almost every entry. Washington Irving's page on going into the country, from The Sketch Book of 1820, holds 499 characters together with semicolons and nothing else. And Thomas Jefferson filled his Notes on Virginia of 1785 with river measurements, so the Great Miami passage puts figure after figure into 496 characters, which is the nearest thing here to typing out a settings file. All three are waiting in the typing test, each with its author, year and source on its own page.