 <p>What you might be seeing is that until the alert box is dismissed, the code afterwards is not executed. The alert command is a blocking one.</p> <p>Perhaps you can use <code>console.log()</code> for debugging purposes of this feature. This will not block your code and it will be executed on the <code>keydown</code> event.</p>