Experiment
Build a lock a stick can't open
Five little pins, and only the right key lines them up. Build it wrong first: one pin that any stick can lift clear.
From the Short "Why Only YOUR Key Opens the Lock". ▶ Watch the Short
Build a lock: one pin
A cylinder, the plug, turns inside a fixed body. A spring pushes a pin down through both, and it's jammed. A key lifts the pin clear, and the plug turns.
Open it with the key. Then try a flat stick. Then add more pins and try the stick again.
In the lock
Split the pin
Cut the pin in two: a key pin below, a driver pin above. Now the plug turns only when the split sits exactly at the shear line, the thin gap between plug and body.
Find the key height that turns the plug. Then try a key that lifts too far.
The real trick: five pins
Here the key pins come in different lengths. The key is a matching staircase of cuts, putting every split on the line at once. A long key pin needs a deep cut.
Cut a key that opens it: look at how long each key pin is, set a matching cut under it, slide the key in, and turn. Try the flat stick too.
In the lock
Your key's cuts (0 = no cut, 4 = deepest)
Thousands of keys
Each pin has a few possible lengths. Multiply them together and a few lengths per pin make thousands of different keys.
Try your key with one cut a step too shallow. Then try someone else's key.
Try a key
Lengths per pin
What's going on
This is the pin tumbler lock, the most common kind of key cylinder on house doors and padlocks. The key turns a cylinder, the plug, inside a fixed body. A row of holes, the pin chambers, is drilled through both. At the back, a cam or tailpiece on the plug works the bolt.
The one-pin lock in step 1 is made up, not a real design. With one solid pin, any lift that clears the plug opens it, however it's done. That's why real locks split each pin in two: a key pin at the bottom, which touches the key, and a driver pin above it, under a spring.
The shear line is where the plug's outer surface meets the body's inner surface. With no key in, the springs push the driver pins down across it, and anything crossing it stops the plug turning. The right key lifts each key pin so that the split sits exactly on the line: every driver pin wholly in the body, every key pin wholly in the plug. Lift one too little and its driver pin still crosses the line; too far and its key pin does.
Key pins come in a set of lengths matched to the depths of the key's cuts. House locks usually have five or six pin stacks; some have four or seven. With five stacks and five to ten possible lengths each, that's about three thousand to a hundred thousand different keys in theory. Makers rule some out, but it's still thousands or more. It also means a key isn't unique: any key cut to the same pattern works.
Once the plug has turned, the key pins are pressed down by the body's inner wall, so they can't rise up the slopes of the key's cuts: the key can't come out until you turn it back. Pull it out, and the springs push the driver pins back across the line. Locked again.
Simplified: the lock is drawn many times larger, cut away and seen from the side, with pin ends drawn flat (real ones are often rounded or pointed) and the gaps exaggerated. The turn is shown in the end view, while the parts inside the plug fold away as they would seen from the side. In step 1 the made-up key and stick reach right up to the shear line, and in step 2 the lift is set by trying flat keys of different heights. The number of keys counts every pattern, before makers rule any out. In step 3 you can match the cuts to the pins only because the lock is drawn cut open.