When you insert the key into the lock and turn it to the right, the lock opens. When you turn it to the left, it gets locked. The heart is the lock; the mind is the key.
You get attachment when your mind is turned towards the world. When it is turned towards God, you attain liberation. It is the same lock and the same key that are responsible for bondage and liberation.