How does a master key work?
The super of our apartment building is always going into everyone's apartment when something needs to be fixed. There must be a hundred apartments,
but he only carries one key around with him. How does he get into all those apartments with the same key?
Although locks come in all shapes and sizes, with many innovative design variations, most locks are based on fairly similar concepts. The most common lock design is the cylinder lock. In this design, the key turns a cylinder, or plug, which turns an attached cam. When the plug is turned one way, the cam pulls in on the bolt and the door can open. When the plug turns the other way, the cam releases the bolt and a spring snaps it into place so the door cannot open.
The key your "super" is using is called a master key. To understand how master keys work, you first have to have a basic idea of how locks and keys work.
Inside a cylinder lock, there is a sort of puzzle, which only the correct key can solve. The main variation in lock designs is the nature of this puzzle. One of the most common puzzles is the pin-and-tumbler design.
Source : home.howstuffworks.com