Order changed
why have you locked the door? I don't have key - no. Needs an article
why have you locked the door? I don't have a key - correct
why have you locked the door? I don't have the key - correct
They mean different things.
a key = any key, as if this lock has many keys and you don't have any of them with you.
the key = THE one key you are talkiing about. Usually interpreted to mean your key.