If you want a few possible ways to have the door be locked:
1. You could have the key fire out a signal when you collect it, and have the door receive that signal. Have the door have an area 2d, and use the method in the inspector labeled upon body entered. If a body enters the door's area, and it never received the signal from the key, then it pushes the body to the left a few pixels, causing the player to never be able to enter until they get the key.
2. You can also achieve this by having a global script that can be received by every object in the environment. I like to label it Global, so use that for a reference for my later points. Have a variable in this global script called unlocked, and have it be a boolean that is false. When the player walks onto the area 2d where the door is as mentioned above, then if !Global.unlocked, player.position.x -= 3 (random number, however many pixels you want). Then, when the key is collected, make Global.unlocked = true, and the above statement won't stop the player.
Idk how you implemented any of the models, but this should help for making that kind of thing happen in Godot.