Using keydown event handler for detecting enter key press

Posted on 13-03-2017 by Nadir Latif


The keydown Javascript event handler can be used to listen for key events.

The event handling function takes one parameter which is the Javascript event object. It has the property keyCode which is the ascii code for the key pressed. For example to listen to enter event, we need to check if the event.keyCode value is 13