Skip to content

Typing Brackets and Symbols on Any Layout

Published: · 5 min reading time · Updated:

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.

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.

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.

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.

Pick a text

Every passage is in the public domain. Author, year and source stand on its page.

Britannica 1911: old English standards

Encyclopaedia Britannica · 1911

The eleventh edition of the Encyclopaedia Britannica appeared between 1910 and 1911 in twenty nine volumes, and its copyright has long expired. This passage lists old English and Scottish standards by year, from 1495 to 1618, including the Stirling jug used for the Scots pint. Dates in brackets and semicolons between them make it a precise exercise for the number keys. Wikisource has transcribed the whole edition article by article.

Type this text

The Sketch Book, going into the country

Washington Irving · 1820

The Sketch Book of Geoffrey Crayon came out in parts in 1819 and 1820, while Irving was living in England. The same book holds Rip Van Winkle and The Legend of Sleepy Hollow. It was one of the first American books to sell well on both sides of the Atlantic. Project Gutenberg carries the whole collection.

Type this text

Notes on Virginia: the Great Miami in figures

Thomas Jefferson · 1785

Here Jefferson measures the Great Miami and the Salt River in yards and miles and gives the length of two portages. The figures follow each other closely, 200, 75, 30, 50, 70, 80 and 25, which is what makes the passage a drill. He compiled them from surveyors, traders and army reports, since he had not travelled there himself. The queries he was answering reached him from Paris in 1780.

Type this text

More from the blog

Typing Practice for Coding, and Why the Number Drops

Code is dense in shifted characters, has no word shapes to anticipate and is edited by autocomplete, so prose WPM does not transfer.

Read the article

Dvorak and Colemak Compared With QWERTY

Colemak changes 17 keys from QWERTY, Dvorak rearranges nearly all. Home row contents, relearning cost, and when neither layout is worth it.

Read the article

How to Change and Check the Keyboard Layout in Windows

Two shortcuts change the layout in Windows, and one fires by accident. How to add, remove and confirm a layout before blaming the hardware.

Read the article

ISO vs ANSI Keyboard Layout Differences Explained

Enter shape, left Shift width, one extra key and the backslash position: 105 keys against 104, and what that costs at the keycap shop.

Read the article

Tools

Keyboard test

Press a key and watch it light up. It shows keys that stay silent, keys that fire twice, and how many keys your board reads at once.

Check your keyboard

Typing test

A hundred short texts, from Aesop to the US Constitution. You get speed, accuracy and a map of the keys you keep missing.

Measure your speed