Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
Input Box Freezes After Pressing Escape Key on an Alert Message Box on Chrome/Edge on Windows

I am showing an alert() message in the onkeyup event of an input element when the user presses the enter key. If the user presses Ok button or presses Enter key to close the alert box, everything is fine. But when the user presses the Escape button to close the alert, the textbox freezes. It wouldn't be focused on, won't be typed on, as if it is disabled.

How do I fix that?

Note: the problem won't appear in jsfiddle

EDIT:

I believe the behavior is different if the code is hosted in sites like jsfiddle, even in the Run Code Snippet here in SO. Please try to replicate the problem by actually saving the code in an html file. then run it locally

UPDATE:

I'm using Windows 10. I found out problem only happens on Google Chrome/Microsoft Edge. It doesn't happen on Firefox.

I was able to replicate the problem in virtual machine in cloud. Google Chrome on Windows Server 2022. I even used its On Screen Keyboard to make sure it is not a hardware problem.

window.addEventListener('DOMContentLoaded', () => {
  document.getElementsByTagName("input")[0].onkeyup = function(event) {
    if (event.keyCode === 13) {
      alert('Press Escape Key. The textbox will freeze.');
    };

  }
});
<input placeholder="Press Enter Here" />

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I tried saving the code in an html file and running it locally. But the code works fine. The input box works fine for me and didn't get freeze by pressing Escape button. Even when I tried running the script in this stackoverflow site, it worked here too.

window.addEventListener('DOMContentLoaded', () => {
  document.getElementsByTagName("input")[0].onkeyup = function(event) {
    if (event.keyCode === 13) {
      alert('Press Escape Key. The textbox will freeze.');
    };

  }
});
<input placeholder="Press Enter Here" />

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda