|Late Medieval lock from Newcastle-upon-Tyne|
A pin-tumbler lock—that uses internal pins (sometimes) of varying lengths that require a matching key pattern before they are in the proper alignment to allow the lock to open—was first patented in 1784 patent by Joseph Bramah. The modern version with which we are familiar today was patented in 1848 by Linus Yale Sr., and then modified by Linus Yale Jr. in 1861.
|Mechanism of Egyptian pin-tumbler lock from Nineveh|
Between Khorsabad and Yale, the pin-tumbler lock was used all over Europe and Asia, changing very little in mechanics, but a lot in art design. As metal-smithing became more refined, the locks and keys became more complex. Locks and keys also became works of art, designed to fit visually with their intended purpose.
In medieval Europe, with men going off to war, important keys—to doors, chests that held valuables, coffers that held the lord's seal (needed for official documents) would be left with the trusted lady of the castle, the chatelaine (from Latin castellan, the "lady of the castle"). The symbol of the chatelaine became a cord or belt from which hung several keys. This led to the term "chatelaine" (still in use) to mean a chain or dangling clip used to organize items, such as a small pair of sewing scissors on a long chain.
*If you care to do your own searches on this topic, you'll frequently find the oldest lock is said to be 4000 years old or from 4000 BC. Since the references agree it was found in Khorsabad palace, which was built by Sargon II, who ruled 721-705 BCE, I have to assume online sources have been careless in their reporting of its age. Smith College is a little more careful with its description.