locks and keys
A lock is a mechanism fitted to a door or case to prevent entry to people other than those with a specialized key or other device. The earliest known mechanical lock is from ancient Egypt, c.2000 B.C. The bolt was hollow, with a number of holes bored in its top; one of the bolt staples held a number of wooden pegs which fell into the holes in the bolt, holding it in place. The key could be fitted into the bolt; it had spikes in the same pattern as the holes, and thus could lift the pegs clear. The ancient Greeks situated their locks on the inside of the door, access being achieved via a keyhole to whose shape the key conformed. The Romans improved the Egyptian design by having pegs of different shapes and using springs to drive the pegs home; and invented the warded lock, whose key must be slotted to clear wards, obstacles projecting from the back of the lock.
The modern lever-tumbler lock was invented Robert Barron (1778): levers fit into a slot in the bolt patterned such that each lever must be raised a different distance by the key to free the bolt. Jeremiah Chubb added another lever to jam the lock if another key were tried (1818). The Bramah lock, invented by Joseph Bramah (1784), has a cylindrical key slotted to push down sprung sides, each of which must be depressed a different distance to clear an obstacle.
Most domestic locks are now Yale locks, invented by Linus Yale (1861). An inner cylinder plug has holes into which sprung drivers press pins of different lengths. The key is patterned to raise each pin so that its top is flush with the cylinder, which can then turn. Modern safes have combination locks and time devices so that they can only be opened at certain times.