A key can become jammed in a lock for a variety of reason. There could be dirt in the lock, the mechanism may require lubrication, or something in the lock may be broken. Regardless of the reason, if the key won't turn, you will need to take additional steps in order to unlock the door. The following strategies may help if you perform them carefully so that the key doesn't break off in the lock.
1. Gentle Jiggling
Trying to force the key to turn is the worst thing that you can do. Instead, jiggle it gently from side to side. If there is a piece of debris or a stuck mechanism, gentle jiggling may be all that is needed to get the key to finally turn. If the entire lock base seems to move with your key, use one hand to hold the lock base still while jiggling with the other hand. You can also use a monkey wrench or a clamp to hold the lock base in the event you can't grasp it easily with your hands.
2. Spray Lubricant
Keys most often become stuck because the lock needs to be lubricated. Taking the time to spray a lubricant into your locks once or twice a year will prevent this from happening. Lubricant may also help if the key is already stuck. Using a spray lubricant with an applicator straw, place the tip of the straw as much into the lock as you can with the key in the way and give a short spray. Jiggle the key slightly to help work the lubricant into the lock. Then, slowly turn the key, jiggling a bit as you go. In many cases, the key will finally be able to turn. The lock will need to be cleaned and fully lubricated once the key is out.
3. Ice It Up
You may be able to use some basic physics to free the key. Metal, like many other materials, shrinks slightly when it is cold. This isn't enough for you to notice with your eyes, but it may be enough for the key to slip free of the lock. Applying an ice pack to the lock for a few minutes may be all you need to do to free the key. You can also try spraying canned air, the type made to clean electronics, into the lock, as this will also cause the metal to become cold and possibly shrink.
Don't force the key if it simply won't turn after trying the above techniques. If the key breaks, it will be even more complicated to fix the issue. Instead, call a locksmith in your area for more help.
To learn more, contact a resource like Bob's Lock & Key.