mercredi 29 août 2018

why setting input.value equal to empty string doesn't remove recently pressed key?

In below code if I press 'a' after some keys it should remove everything from input including but 'a' is not going away in below code.

const input = document.querySelector("input");

function type(e) {
  if (e.key === "a") {
    console.log("helo");
    input.value = "";
  }
}
window.addEventListener("keydown", type);

Aucun commentaire:

Enregistrer un commentaire