Keys are clear symbols of freedom and opportunity in dreamland. They are also symbols of home ownership and trust, as you only give the keys to your home to people you trust. Bear in mind, though, that jailers also carry keys, so they can also be symbols of restriction and confinement.
If your unconscious highlighted a key in your dream, it could have been drawing your attention to any of these symbolic associations or reflecting your waking hopes and fears.
Keys might also represent an explanation or solution to a dilemma that has been worrying you. This is especially the case if your dream key fitted and a lock opened, as locks are symbolic of obstacles to success and self-knowledge. Where the lock was located in your dream may be significant.
If it was on a door, this is a symbol of transition or opportunity, but if it was on a cupboard, box or safe, this can represent your true nature and hidden inner qualities that are latent or repressed. If, however, the key, code or password did not match the lock in your dream, this could be a suggestion that you need to look elsewhere if you want to unlock or release the insight that will help you find a solution. According to Freud, keys are phallic symbols and the lock can signify the vagina, so if you dreamed of a key being inserted into a lock, the dream may have had an erotic significance. On the door of whose house was the lock that was being unlocked?
[1]According to Freudian analysis, a lock is commonly interpreted as a symbol of the female sexual organ with the key representing the phallus. A dream of unlocking a box of treasure may indicate sex as liberating. If, however, the box won’t open this indicates sexual frustration or dissatisfaction with the sexual side of a relationship.
[2]