A portion called the latch is partially in and out of the lock cylinder when the door is locked. If the door is unlocked, the latch stays inside the lock cylinder. The latch can only be disengaged and the door unlocked with a key. If you inserted the wrong key, the pins wouldn’t be aligned...
To give you an idea, it's an adjustable bar fitted on the hitch to ensure that the trailer does not wobble while being pulled. If you have a modern rig, it most likely already has a built-in sway bar.