Here's a very simple example - two rooms, with a single exit back and forth. That exit is locked. Also in the room you have a key.
So, go to the 'exit' tab on the room with the locked door, click on the exit at the bottom where it says 'To' and 'Alias', then click 'Edit'.
Then make the UI look this this:
If you'd rather use code, click the tab I've highlighted and add this:
if (Got(key)) {
MoveObject (player, room 2)
}
else {
msg ("That door is locked")
}