This won't work, since the input value is only checked once when the page loads. This check should be moved inside the keydown handler.