Mechanical or electronic device for securing a door or receptacle so that it cannot be opened except by a key or a code. The lock originated in the Middle East; the oldest known example was found near Nineveh. Possibly 4,000 years old, it is of the pin tumbler type, otherwise known as an Egyptian lock. The Romans were the first to use metal locks and to make small keys for them. They also invented wards, projections in the keyhole that prevent a key from turning unless it has slots that avoid the projections. Probably the most familiar lock today is the cylinder lock, a pin tumbler lock opened by a flat key with a serrated edge; the serrations raise pins in the cylinder to the proper heights, allowing the cylinder to turn. Also common are the unit lock, housed within a rectangular notch cut into the edge of a door, and the mortise lock, housed in a mortise cut into the door edge, the lock mechanism being covered on both sides. Other types include lever and combination locks. Electronic locks that open with a magnetic card key are popular for banks, hotel rooms, and offices.