Problem with in game action

OK my game is below (yes i am just starting)
so my problem is when you pick up the key in room 1 and go to room 2 the key disappears from your inventory slot and goes back onto the floor in room 1. It is supposed to (if you can’t tell from the code)
go in inventory
go to room 2
key still in inventory Click key
door opens + key disappears
(if you go back to room 1 key is still gone and door is still open in room 2)
click door
win game
This is not happening so I am asking you guys for some help.