You are here: Home page > Home life > Locks

Close-up of the pins in a cylinder tumbler lock

Locks and keys

Dangerous criminals, gold bars, glittering jewels—what do they have in common? All are kept secure by locks and keys. Would the world be a happier place if no-one had invented such things? It just might be!

Imagine it for a moment. Anyone could steal anything, so perhaps no-one would bother owning very much or wanting anything more. No-one would live in a fancy house with valuable belongings, swan around in a luxury car, or earn more money than they could carry in their pocket. Perhaps that would be a better world, but it's not the one we live in! In our materialist modern age, we buy stuff, earn money, and buy even more stuff. We are what we own—and the only thing standing between a lifetime of slowly accumulated, valuable possessions and instant poverty is the lock on the door. Locks, then, are pretty important things, but have you ever stopped to wonder how they work? Let's take a closer look!

Photo: Most door locks have rotating cylinders and pins that slide in and out holding them securely in place until you insert the right key. Here you can see the cylinder removed from a door lock and the pins ready to pop out when the key is turned. Photo by Nicholas Alder courtesy of US Air Force and DVIDS.

Sponsored links


  1. What is a lock?
  2. How do locks work?
  3. How a mortise lock works
  4. Types of locks
  5. How Yale locks work
  6. Who invented locks?
  7. Find out more

What is a lock?

In the very broadest sense of the word, a lock is a device that keeps valuables safe or restricts access to something that needs protecting. A lock can hold things out (protecting homes from intruders and banks from thieves) or keep them in (holding criminals in jail or animals in zoos).

Simple door key - decorative image only.

Photo: A lock isn't simply something that's opened by a key: it's a piece of compact mechanical engineering that converts the rotary (turning) motion of your hand into reciprocal (back-and-forth) motion of the bolt that locks or opens something like a door.

Before the modern electronic age, locks were entirely mechanical and based on intricate mechanisms made from levers, wheels, gears, and cams. During the mid-20th century, locks became more sophisticated and automated and started to incorporate electrical and electronic mechanisms. But now information is valuable too and most of it is held inside hundreds of millions of computers that are all linked together through the Internet. Modern locks that protect computers are based on encryption—a way of securing information using complex mathematical processes.

How do locks work?

Most mechanical locks are fitted to things like doors and cupboards and have two physically separate parts. One part is fitted to the frame (the static part of the door) and is essentially a sturdy, metal reinforcement for a hole cut into the door itself (to prevent the locked door from being opened with brute force). The other part of the lock fits into a rectangular hole in the door (known as a mortise) and consists of a metal mechanism that moves a heavy bolt into or out from the reinforced hole. The bolt slides from side to side when you turn a key clockwise or anticlockwise, so it has to be operated by a mechanism that can convert rotary motion (the turning key) into reciprocating motion (the sliding bolt)—something like a cam or crank. If that were all that a lock consisted of, every key would be able to open every lock. So the other essential part of a lock's mechanism is a set of fixed or moving metal pieces (wards or tumblers) that engage with slots cut into the key, ensuring only one key can rotate, turn the cam, slide the bolt, and open the door.

How a mortise lock works

Most sturdy external doors are protected by mortise locks. Typically the lock mechanism is built into the door so you can't really see it. In my garden shed, the lock is mounted on the inside of the door, so some of the parts are visible. In this case, the locking mechanism (the deadbolt) is operated by the key, while the latching mechanism (the latchbolt—which keeps the door closed when it's unlocked) is operated by the handle. In this lock, the two mechanisms are completely separate.

The main parts of a mortise lock on a shed door.

Photo: A typical mortise lock on a garden shed door. The white-labeled mechanism (the lock) is entirely separate from the black-labeled mechanism (the latch).

What's happening inside?

In a mortise lock, the key rotates and slides a bolt in and out of the door frame as it does so. Although locks like this can be very intricate and complex, I've simplified the mechanism to its absolute basics so it's easy to understand.

Animation showing how a mortise tumbler lock opens and closes.

Animation: How a mortise lock works

With the door locked, the bolt (gold, 1) is extended into the mortise (hole) in the doorframe. The key (gold, 2) is in a vertical position in the lock. The bolt is held securely in place by metal levers called tumblers (3), cut to various sizes to match the notches in the key. I'm showing just two tumblers for simplicity, one red and one green, but there are usually more. The tumblers are held in place by springs (blue, 4). When you turn the key (5), each of its notches moves one of the tumblers upward (6). The red tumbler has to move further than the green one, so the key would need to have a smaller notch for the red tumbler and a bigger notch for the green one. When all the tumblers have moved out of the way, the bolt slides to the right (7) and the door can open.

Sponsored links

Types of locks

There are several different types of locks and they all work in a slightly different way. Ward locks are among the oldest and simplest. From the outside, they look much like any other lock. Inside, they they have curved, jutting out pieces of metal fitted inside them (called wards) that exactly line up with the holes in a particular key. Other keys can be inserted into the lock but the wards will stop them from turning. Since they're relatively crude and fairly easy to pick, ward locks are no longer in common use, except for very low security applications.


Photo: A secure padlock like this has a cylinder, pin-tumbler lock inside it. Padlocks like this are generally made from hard and rustproof metals. The body (the gold-colored part) is brass (an alloy of copper and zinc) and the shackle (the loop at the top that opens and closes) is made of hardened steel, designed to stop you sawing through it.

Tumbler locks can trace their origins back to ancient Egypt, but the kind we use today are a more recent (19th-century), more sophisticated, and much more secure design—best known to most of us in the form of the cylindrical pin tumbler or Yale lock (developed by Linus Yale, Jr. in the 1860s). All kinds of variations on this basic design exist; if you search the US Patent and Trademark Office database for "cylinder lock," you'll find well over 500 different ones! Padlocks operated by keys are essentially portable, miniaturized Yale locks with super-small cylinders and pin tumblers. Read more about Yale locks in the box down below. Combination padlocks work in a slightly different way, as the animation here explains.

Animation showing how a combination padlock opens and locks.

Animation: How a combination padlock works: A padlock like this has three, four, or five rotating metal discs (gray) with small invisible holes called gates (black) cut into them. A central bar running through the middle of the lock has small notches on it that are held firm behind the discs when the lock is securely closed. When you select the correct combination (in this case, 3-1-7-0), the gates line up with the notches in the central bar. A spring (blue) at the end of the lock pushes the bar out, the notches slide through the open gates, and the lock opens.

Electronic locks do away with metal keys altogether; you've almost certainly use one if you've stayed in a hotel recently. Instead of a key, you have a plastic card (similar to a credit card) that has a magnetic strip on the back. When you slide the card into the lock, an electronic reader circuit decodes the information on the strip and checks for a match with a code stored inside it. If it's the right key, the circuit activates a powerful electromagnet that pulls a bolt sideways, allowing you to open the door.

A handheld chip and pin two-factor security device used by the Cooperative Bank.

Photo: Electronic key: Some banks are now giving a two-factor authentication device like this to their customers. When you put your credit or debit card into it, it generates a number that you type into a banking or shopping website to use as a kind of one-off, disposable password. So it's a bit like an electronic key that opens an online lock.

With traditional mechanical and electronic locks, there's still one basic security flaw: if someone else has your key, they can open your lock and steal your things. That's why the latest forms of security incorporate biometric locks (featuring things like fingerprint readers or iris scanners) that grant access to a specific person rather than just any old person who happens to have the matching key. Sooner or later, sometime in the future, it's likely that most locks will have some form of biometric security checking built in.

If you're using a computer, a password (or passphrase) is the equivalent of a key granting you access to a particular machine, network, website, or whatever it might be. Just as a key can be stolen, so can a password—but the added problem with passwords is that they can be guessed (or different ones can be tried again and again until the right one finally works). That's why really secure computer systems (such as online banking systems) are now using a kind of enhanced security called two-factor authentication: to gain access, you have to know one or more passwords and possess a physical device (called a token) that generates a one-off (disposable) security code you enter as a kind of extra password. Read more in our article on security tokens.

How Yale locks work

One of the most common kinds of lock is the cylinder pin-tumbler lock used in padlocks and Yale door locks. Based on a mechanism invented in ancient Egypt, it became a winning invention in the mid 19th century thanks to the efforts of American inventor Linus Yale, Jr. (1821–1868) and the Yale company named for him.

Do you have a Yale-type lock on your door at home? Maybe you have a padlock you use to chain up your bicycle? The heart of a lock like this is a sturdy metal cylinder that can swivel inside an equally sturdy metal housing. When the correct key is in place, you can turn the cylinder freely and open the lock; without the key (or with the wrong key inserted), the cylinder refuses to turn and the lock stays shut.

Padlock cylinder Yale lock key
Photo: 1) Turn the padlock over and you'll see the cylinder underneath. Held in place by metal pins inside, the cylinder will rotate only when push the correct key inside it. 2) Keys that fit this kind of lock have a jagged profile.

If you could open up a lock like this—not an easy job, by any means!—you'd see that the secret is a series of thin metal pins that run down from the housing into the cylinder (1), locking it in place. In fact, there are two separate sets of pins, an upper set (3, colored red here) and a lower set (4, colored blue). A set of small springs (2) just above the pins keeps them in place. How does it all work?

Without a key in the lock, the upper pins drop down from the housing into the cylinder, locking it in place, as shown in the first picture below.

artwork showing pin tumbler padlock mechanism with the lock shut artwork showing pin tumbler padlock mechanism with the key in place and the lock open

How does it open? Every key has a slightly different profile of raised areas so it fits only the lock it's intended to. When you push the jagged edge of the correct key (5) into the lock, it pushes the pins upward against the force of the springs (6). The further in you push the key, the more pins it lifts. With the right key in place, the upper pins are all pushed just above the edge of the cylinder so they no longer lock it to its housing. When you turn the key, there's nothing to stop the cylinder rotating, so the lock opens.

Yale's original lock, patented in 1844, wasn't exactly like this, but it was very similar. I've dug out the patent drawings (below), edited them a little bit, and colored them in so you can see for yourself how everything works:

Edited version of Linus Yale's 1844 pin tumbler lock patent drawings

Artwork: One of Linus Yale's original lock designs, dated June 13, 1844. Artwork courtesy of US Patent and Trademark Office from US Patent 3630: Door-Lock.

You can see there are two cylinders, a green one inside a yellow one, locked together by the pins (red and blue) that are held in by four curved outer springs (orange). The key (on the left) is a slightly different shape from a modern Yale key: it's more like a cylinder with notches cut into the ends. When you insert it into the lock, it pushes the red and blue pins outward so the green cylinder can turn freely inside the yellow one, and either open or close the bolt (on the left, labeled B) depending on which way you turn it. On the right hand side, you can see the pins exploded in a bit more detail. If you're interested in reading more, check out US Patent 3630: Door-Lock by Linus Yale, which is his own, original description of his invention.

Linus Yale continued to refine his design for the next 20 years or so and, in 1868, built a factory in Stamford, Connecticut for mass-producing his locks with his partner Henry R. Towne.

Who invented locks?

An Elizabethan link plate chest lock.

Artwork: This 16th/17th century Elizabethan link plate chest lock was a work of art and precision engineering. Illustration from A Treatise on Fire and Thief-proof Depositories, and Locks and Keys by George Price, Simpkin, Marshall, & Co., 1856, p.196 (public domain).

Here are a few quick milestones....

Sponsored links

Find out more

On this website

On other websites



Please do NOT copy our articles onto blogs and other websites

Articles from this website are registered at the US Copyright Office. Copying or otherwise using registered works without permission, removing this or other copyright notices, and/or infringing related rights could make you liable to severe civil or criminal penalties.

Text copyright © Chris Woodford 2008, 2021. All rights reserved. Full copyright notice and terms of use.

Follow us

Rate this page

Please rate or give feedback on this page and I will make a donation to WaterAid.

Tell your friends

If you've enjoyed this website, please kindly tell your friends about us on your favorite social sites.

Press CTRL + D to bookmark this page for later, or email the link to a friend.

Cite this page

Woodford, Chris. (2008/2023) Locks and keys. Retrieved from [Accessed (Insert date here)]


@misc{woodford_yalelock, author = "Woodford, Chris", title = "Locks and keys", publisher = "Explain that Stuff", year = "2008", url = "", urldate = "2023-08-07" }

More to explore on our website...

Back to top