Deep DivesQWERTY Keyboard

Why Your Keyboard Looks Like This: The Story Behind QWERTY

The keyboard you use today is a relic of the past. Every keystroke carries the weight of a century-old design, a reminder of an optimization problem.
QWERTY keyboard - Introduction

The QWERTY keyboard, named after six letters, was not born from linguistic theory or ergonomics. It was not designed for efficiency or ease, but to survive. QWERTY's roots lie in Physics, Mathematics, and Engineering.

In the world of typewriters, every keystroke triggered a levered arm swinging toward a shared metal ring. If two arms were to strike too quickly, it would lead to a collision, and hence a mechanical deadlock that engineers called a "jam".

Ribbon× CollisionTH
Typebars collide when struck in rapid succession → mechanical jam

Christopher Latham Sholes, a newspaper publisher and politician, treated each typebar jam as an experiment. After hundreds of iterations and many trade-offs, he co-invented the QWERTY layout to reduce collisions.

In practice, the 'QWERTY meaning' is simple: reliability and survival over comfort and speed.

This is the story of how mechanics, economics, and human behavior combined to produce a system that we use every single day. The compromises made over 150 years ago still govern every keystroke we make, whether it is on a physical keyboard or the taps on our smartphone screens.


01

The Algorithm of Survival

QWERTY keyboard - The Algorithm of Survival
Before computers had crashes and codes had bugs, typewriters had jams.

In the typewriters of the 19th century, every keystroke was a small act of physics: a metal arm (called the typebar) swung upward to strike an inked ribbon. Forty-two such arms sprang out from a semicircular type basket, all sharing a single narrow path toward the printing point. When two neighboring typebars were activated in quick succession, their trajectories intersected, locking the machine in a tangle.

For Sholes, the challenge here was clear: reduce collisions without rebuilding the entire mechanism. Each pair of letters (called a digram, meaning a common two-letter sequence such as TH or HE) had a measurable collision frequency. Letters that jammed the most often had to be placed farther apart around the arc of the typebasket.

While Sholes lacked formal training in mathematics or physics, we can now describe his method with modern formalism. The jam rate J resembles a pairwise potential model, where frequently co-occurring letters exhibit a repulsion-like interaction that pushes their typebars apart.

J ∝ Σi,j fij g(dij)

Variables:

  • fij is the frequency of digram ij
  • dij is the angular distance between the typebars of i and j
  • g(d) is a decreasing function of distance

Sholes never wrote this equation, but he performed it experimentally, i.e., move a letter, count the jams, repeat. QWERTY began as a physical algorithm for reliability, an emergent equilibrium between probability, geometry, and hardware constraints.

“QWERTY began as a physical algorithm for reliability, an emergent equilibrium between probability, geometry, and hardware constraints.”

02

The Rigorous Experiment

QWERTY keyboard - The Rigorous Experiment
Once Sholes had identified the mechanics behind jams, he adopted a pragmatic, experimental approach to search for a solution.
Key Change

From Alphabetical to Scattered: Breaking the intuitive A-Z pattern to prevent common letter pairs from jamming

Early prototypes resembled small pianos with two horizontal rows of alphabetically arranged keys. Frequent diagrams such as TH, HE, ER, AN, and ST repeatedly collided, halting the carriage.

Early Alphabetical Layout (Piano-Style)
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Result: High collision rate for common pairs (TH, HE, ER, ST)

Sholes' letters to his partner James Densmore (1868–1873) describe hours spent in cataloging these collisions.

These letters, according to the Wisconsin Historical Society Archives, include partial layouts and notes on specific key jams, such as E and R. Densmore's feedback paved the way for readjustments and further testing.

The typebars in these prototypes pivoted radially, and adjacent arms shared axes; thus, proximity had a direct impact on collision probability.

According to his correspondence with Densmore, Sholes spent days recording how often the typebars got locked. He swapped letter positions and timed the delays between keystrokes.

Even the failures in the process were important data points as they gave useful information about the placement of keys. Sholes was essentially minimizing the probability of jams with the help of the function:

“Even the failures in the process were important data points as they gave useful information about the placement of keys.”
Σi,j fij g(dij)

Through these cycles, the QWERTY layout became an emergent data-driven system. However, even with careful rearrangement, collisions could not be fully eliminated, and this constraint continued to guide later design decisions.


Exercise 1

Layout Comparator

Compare QWERTY with an alphabetical layout to understand the trade-offs Sholes made.

Alphabetical Layout

Early typewriters used alphabetical order—intuitive but prone to jams. Adjacent letters like S-T or H-I appeared together frequently in English text.

The Jamming Problem

When typebars for adjacent letters were physically next to each other, typing common sequences like “THE” caused constant collisions and mechanical lockups.

QWERTY's Solution

Sholes scattered common letter pairs across the keyboard. T and H are separated, reducing collision probability despite increased finger travel.

Try it: Switch between layouts to see how QWERTY spreads out the letters “THE”. Notice the trade-off between intuitive layout and mechanical reliability!

Q
W
E
R
T
Y
U
I
O
P
A
S
D
F
G
H
J
K
L
Z
X
C
V
B
N
M
Typing: “THE

QWERTY spreads common letters apart to reduce mechanical jams. Letters like T-H are separated across the keyboard.

03

Engineering for Failure

QWERTY keyboard - Engineering for Failure
Sholes' observations were the beginning of a complicated task. His approach, though meaningful, was just the first step in the process. The physics of the typewriter itself played a significant role in QWERTY's design.
Key Change

Vowels Shifted Up: Moving A, E, I, O, U, Y to the upper row to distribute frequent keystrokes across the basket

Around forty-two typebars pivoted within a semi-circular typebasket, each traveling roughly 30–45°. A typebar, on striking the ribbon, recoiled under the tension of the return spring. When a key was released, the bar did not reset instantly. Instead, the spring's tension caused a brief oscillation.

30-45°Print Point
Typebar trajectories converging at single point

During this small window, the arm interfered with the typebar, occupying the same path. If an adjacent key was pressed too soon, the trajectories had a higher probability of overlapping, thus causing the jams. Although the timing was not long (less than a second), it was enough for quick operators to trigger a jam, particularly when typing diagrams such as TH or HE.

As letters frequently used together posed the greatest risk of collision, Sholes started placing them farther apart in the typebasket.

The adjacency problem scales roughly as O(n²), because every pair of typebars is a possible interaction that could lead to a jam.

“The adjacency problem scales roughly as O(n²), because every pair of typebars is a possible interaction that could lead to a jam.”
42
Typebars
n(n-1)/2
850+
Possible Pairings
Insurmountable Tests

For example, to reduce stress on the mechanism, vowels were shifted to the upper row. This design choice distributed frequent keystrokes across the basket, but at the expense of optimal hand ergonomics.

Vowel Distribution Strategy
2
3
4
5
6
7
8
9
-
A
E
I
.
?
Y
U
O
,
B
C
D
F
G
H
J
K
L
M
Z
X
W
V
T
S
R
Q
P
N
Vowels (highlighted) concentrated in second row to reduce mechanical stress

Historical reconstructions of typebar dynamics and Remington manuals confirm these constraints, showing that collision probability, angular separation, and spring mechanics dictated early keyboard layout.

Beyond mechanics, the design of QWERTY was also shaped by material cost and manufacturing constraints – the next layer of its survival logic.


04

0 & 1: The Economics of Absence

QWERTY keyboard - The Economics of Absence
In the earliest typewriters, Remington deliberately omitted certain keys. In Remington's Standard No. 2 Typewriter, for example, there were no keys for "0" and "1". This was a design choice intended to reduce jams and simplify the mechanism.
Key Change

Removed 0 and 1: Substituted with O and I to reduce mechanical complexity and jam frequency by ~5%

Each additional key required a typebar and spring, increasing collision points and maintenance complexity. Omitting two keys would simplify the typebasket and lower the probability of mechanical failure.

"0" and "1" were the easiest to replace (with O and I). Other letters or numbers did not have such intuitive substitutes. Operators quickly adapted to this omission. Typewriter manuals explicitly taught a workaround where "0" was replaced with uppercase O, and "1" was replaced with uppercase I or lowercase l.

0
Missing Key
1
Missing Key
-2%
Friction
-5%
Jams
“Fewer typebars reduced friction by roughly 2% and jam frequency was reduced by approximately 5%.”
Remington Typewriter Layout (No 0 or 1 Keys)
"2
"3
$4
&5
/6
¢7
?8
(9
)—
Lower
Q
W
E
R
T
Y
U
I
O
P
A
S
D
F
G
H
J
K
L
M
Upper
Z
C
X
V
B
N
?
:
;
Notice: No dedicated keys for 0 or 1 — operators used O and I instead

These omissions influenced the keyboard layout itself. The layout of the keyboard shows traces of this substitution practice, where 0 is close to O.


05

Morse and the Telegraph Operators

QWERTY keyboard - Morse and the Telegraph Operators
Although mechanical constraints shaped the skeleton of QWERTY, its flesh was informed by human behavior. Telegraph operators, trained to translate Morse code at high speed, may have left a mark on the layout, although this remains debated amongst historians.
Key Change

Final QWERTY Layout: Optimized for telegraph operator muscle memory, placing frequent letters centrally and rare ones on periphery

Telegraph operators had developed their own habits: sequences of dots and dashes were executed precisely, with the most common letters typed more frequently and numerically-coded messages following specific patterns. Operators relied on muscle memory and precise timing, forming informal conventions to maximize speed and minimize errors.

Remington engineers observed these behaviors, experimenting with layouts to map these high-frequency patterns onto the typewriter.

Frequency-informed adjustments thus became central to the QWERTY layout. Common letters in English were moved toward central, easily accessible keys. Rare letters were pushed to the periphery.

“Frequency-informed adjustments thus became central to the QWERTY layout. Common letters in English were moved toward central, easily accessible keys.”
Morse Code Influence on QWERTY Placement
Letter
Morse Code
Frequency
QWERTY Position
E
·
High
Central, accessible
T
High
Central, accessible
S
· · ·
High
Central, accessible
I
· ·
High
Near 8 (for years)
Q
− − · −
Low
Periphery
Z
− − · ·
Low
Far from SE
·Dot (short signal)
Dash (long signal)

Error mitigation was another driver. Letters frequently confused in Morse, such as Z (− − · ·) versus the digram SE (· · · / ·), were intentionally separated, reducing mis-strikes.

Ultimately, QWERTY balanced mechanical limits and operator habits into a single layout.

Final QWERTY Layout (1873)
Q
W
E
R
T
Y
U
I
O
P
A
S
D
F
G
H
J
K
L
Z
X
C
V
B
N
M
Optimized for telegraph operators and mechanical reliability

06

Digram Math: The Hidden Graph

QWERTY keyboard - Digram Math: The Hidden Graph
Although Morse code habits shaped QWERTY's rhythm, the underlying structure still obeyed the math of collisions. A century later, linguists and historians reconstructed Sholes' reasoning by mapping common letter pairs (digrams) to their relative physical positions on the original QWERTY typebasket.
Key Change

Optimized Letter Pairs: Common digrams like TH and HE separated widely, while some pairs like ER remained adjacent due to engineering constraints

Letters that jammed most frequently, such as TH or HE, were found to be placed deliberately far apart in the basket. Yet the layout was not mathematically perfect. Pairs like ER, though common, remained neighbors, revealing that practical engineering constraints sometimes overrode ideal separation.

TH
~31% frequency
Widely separated
ER
~28% frequency
Adjacent
HE
~26% frequency
Widely separated
IN
~22% frequency
Moderately separated
AN
~20% frequency
Moderately separated

From this data emerges a typebasket behaving like an implicit optimization graph: letters as nodes, their mechanical proximities as edges, and jam probability as weighted connections. Through repeated trial, error, and iteration, Sholes effectively minimized this function across all digrams:

“A typebasket behaving like an implicit optimization graph: letters as nodes, their mechanical proximities as edges, and jam probability as weighted connections.”
Σ (frequency × proximity)

This solution to a constrained optimization problem made QWERTY a mechanical graph encoding both physics and probability.

QWERTY, therefore, was not an arbitrary invention, but an early case of constrained optimization. It served as a mechanical graph encoding both physics and probability, and providing a framework for human hands to adapt.


Exercise 2

Digram Analyzer

Analyze letter pairs (digrams) in any text and see how QWERTY handles them.

What Are Digrams?

Digrams are two-letter sequences. In English, “TH”, “HE”, “IN”, and “ER” are the most common. These frequent pairs were Sholes' primary optimization target.

Same Hand Problem

When both letters of a digram are typed by the same hand (left or right), it increases jamming risk on mechanical typewriters since typebars on the same side are physically closer.

QWERTY's Strategy

QWERTY strategically places common digrams across different hands. “TH” has T (left) and H (right), reducing mechanical collision probability.

Try it: Paste different text samples—emails, articles, code. Watch how digram frequencies change and notice which pairs would have caused typewriter jams!

78
Letters
21
Digrams

Top 10 Digrams

TH
3×
HE
2×
MP
2×
Same hand
ER
2×
Same hand
IS
2×
SA
2×
Same hand
LE
2×
ET
2×
Same hand
TE
2×
Same hand
TT
2×
Same hand

Blue bars = letters on opposite hands (less jamming). Pink bars = same hand (potential collisions).

QWERTY keyboard - Conclusion

QWERTY is still around, not because it is the easiest to use or it is perfect, but because it is good enough to survive. It's a fossil of nineteenth-century physics, embedded in twenty-first-century software.

Each key carries the inertia of trial and error, of springs and levers, of human adaptation to mechanical rhythm. The typewriter's constraints have long vanished, yet their presence can be felt in every interface we touch.

The physics that once governed typebars now governs thumbs and touchscreens. The optimization problem that Sholes solved in the 1870s persists in the palm of our hands.

Systems survive not by being the best, but by being the most compatible with what already exists. QWERTY proves that efficiency can be adapted by humans and turned into a habit, that human muscle memory can outlast any machine, and that the legacy of smart engineering solutions can shape lives long after the hardware is gone.

Sources

David, P. A. (1985). Clio and the economics of QWERTY. American Economic Review, 75(2), 332–337.

First Practical Typewriter. (2012, October 19). Wisconsin Historical Society.

Harrison, J. (1890). A manual of the Remington standard typewriter. United Kingdom: (n.p.).

KAZ: News, reviews, posts, and upcoming events. (2019). Kaz-Type.com.

Lewand, R. E. (2000). Cryptological Mathematics. Mathematical Association of America.

Mike. (2016, May 15). The Story of James Densmore and the First Typewriter.

Norvig, P. (2012, December 17). English letter frequency counts: Mayzner revisited.

Scientific American. (1872, August 10). The new typewriter and its mechanism.

Yamada, H. (1981). A historical study of typewriters and typing methods.

Yasuoka, K., & Yasuoka, M. (2011). On the Prehistory of QWERTY. Zinbun, 42, 161-174.



[ KEEP READING ]

Learn more

Explore more about how Greptile works


AI Code Review - Greptile | Merge 4X Faster, Catch 3X More Bugs