JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="pw" />

JavaScript

var correct = "password";                                   //Set "correct" to the correct password
 
function isenter(event){
     var pressed = event.which;                                  
      if (pressed === 13){                                    //If key pressed is "Enter"
          var pwinput = document.getElementById("pw").value;  //Set "pwinput" to the value f the password input field (id="pw")
          console.log(pwinput);
          window.alert(correct + " " + pwinput);              //Display values of correct and entered password (for debugging)
          if (pwinput === correct) {                          //If entered password is equal to correct password
              window.alert("Match registered");
			  window.location = "lobby.html";   
         }
         else{
             window.alert("Match NOT registered")
         }
     }
 }

window.addEventListener("keypress", isenter)