A Key grants you to access to a thing with a lock (e.g. Steel Door, Steel Trapdoor, Locked Chest), even if you don't own it. You can obtain keys from other players or making your own from a Skeleton Key. Each key is unique and only fits into one lock. If the locked thing has been removed, the key won't unlock anything.
Usage
Wield the key and right-click on a locked thing to attempt to access it. If the key fits, you perform the action (e.g. you open a door). If it doesn't fit, the key does nothing. You can always smelt keys back to gold ingots when they have become useless.
Creating a key
Keys are made from skeleton keys. See Skeleton Key to learn how to make your own keys.
Smelting
Modding
Mods are able to add more locked things which are compatible with the key system.