title: javascript stop all functions when game is over
body: <p>I need to stop this function from executing:</p>
  
  <pre><code>document.addEventListener("keypress", function(evt) {
  
      evt = evt || window.event;
      var charCode = evt.keyCode || evt.which;
      var charStr = String.fromCharCode(charCode);
  
      checkKey(charStr);
  
      //check loss
      if (attempt == 0) {
          gameLost();
      }
  
      //check win
      underscoreRemain = nameReform.includes("_");
      if (!underscoreRemain) {
          gameWon();
      }
  
      document.getElementById("attempt").innerHTML = attempt;
  });
  </code></pre>
  
  <p>Basically, when the game is either won or lost, it won't take any more key pressed, hence no execution of the rest of my functions. I've looked on w3school and stackoverflow, but the removeEnventListener and other suggested methods don't work.</p>