It's interesting (if you get the chance) to learn how a lock works. And there are several different kind of locks out there, but I think I will just go over the basic ones that are the every day to day type that we all can relate to. Like the mechanical locks, tubular locks - which are the most common type of lock today, and the electronic locks. Let me first start by telling you how the keyed lock works or how the mechanism works. Most keyed locks have a pin and tumbler locking mechanism. Which means that it has a series of spring loaded pins and these are loaded into a series of little cylinders. And each of the little cylinders' bottom is called a pin and a top called a driver. When inserting the key, the springs will be compressed and the key lifts the pin and it pushes the driver into the upper chambers of the cylinder. So when you put in the correct key for the cylinder the bottom and top pins are aligned and the key can turn. The bottom pin will be in the key chamber and the top part of the pin rests on top of the bottom half with gentle pressure of the spring when the key is not in the lock. So when an incorrect key is inserted, the key will not align correctly with one or maybe more of the spring loaded cylinders - not allowing the key to turn by placing at least one of the pins or drivers in the way. Most locks are mechanical. Mechanical Locks operate by one or more pieces of metal (tumblers, levers, or latches) falling into a slot in the bolt, and prevents from being moved. And most mechanical locks require keys to unlock and lock. Tubular locks are a good example of this type of mechanism. And like I said earlier tubular locks are the most common type that most people use on their own homes. Tubular locks are the type of locks that can be installed on a basic door or a standard prepped door. These locks have a keyed cylinder on the outside and turn button or a push button on the inside to manually lock it. Electronic locks operate by an electric current. And are sometimes capable of operating independently with an electronic control assembly that is mounted directly to the lock and allows access by a code or a key.   For more info on other locks, go here.
"How Locks Work" - Author: