Input Box Freezes After Pressing Escape Key on an Alert Message Box

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

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" />