In these cases, you can ask for security to come and assist you. Most hotels have security staff on duty 24/7, and they are equipped to handle situations like this. They will likely ask you some questions to verify your identity and then help you gain access to your room.