If you're new to Godot, you might want to check out some tutorials. There are also some demo projects, too.
If you're asking how to make sure that the player gets the key before approaching the door, I think that the door being closed will ensure that the player looks for a key to open it.
If you're asking how to open the door when the player picks up the key, you should either create a custom signal for the key and then connect it to the door through code, or you should call a function that opens the door when the key is picked up.
Sometimes it's easier to see an example than to have it be explained with a bunch of text, so if you're really stuck I can send you a working example project.