Maybe it's the padlock you use to lock your tool shed, or maybe it's the deadbolt on the door itself -- if it's rusted, you may find yourself on the outside looking in, even if you have the key. The problem is that rust prevents the teeth on the key from sliding under the spring-loaded tumblers in the lock mechanism and pushing them up. It's nothing that a little lubrication can't fix.
Lubricate with Spray Lubricant
Spray lubricants are ideal for freeing rusted locks, because they are formulated to dissolve rust. Be sure your spray can has an extension tube so you can get the spray deep into the lock.
Video of the Day
Push the extension tube into the recess in the nozzle, then insert the end of the tube into the lock and spray a generous amount,. You can't overdo it, although you may find that some of the lubricant drips out of the keyhole. Wipe it up with a rag.
Remove the tube and spray some lubricant on the key. Even if the key doesn't look rusty, the lubricant will help it to slide under the tumblers more easily.
Wait 10 to 30 minutes for the lubricant to dissolve the rust, then try the key. Turn it back and forth several times to see if you can break the rust loose, but don't force it hard enough to break the key off. If it doesn't work, spray more lubricant, wait an additional 10 minutes and try again.
Lubricate with Graphite
Graphite doesn't dissolve rust, but it does lubricate the lock and key mechanism and may help the teeth to slip underneath the tumblers. You can buy graphite lubricant in a squeeze bottle or tube. You can also lubricate the key with a pencil.
Spray graphite into the lock from a squeeze bottle.
Spray some graphite on the key, or rub the key with the tip of a black graphite pencil.
Insert the key immediately into the lock and try turning it. You don't have to wait for the graphite to dissolve the rust, because it won't. Try lubricating the lock and key with more graphite if the key won't turn. If you don't have any success with graphite, you need spray lubricant.