jQuery Keypress enter example

In this post, we will see how to detect if enter key is pressed or not in jQuery.

To capture enter keypress, we will bind dom element with keypress event and if ascii value is 13, then enter key is pressed.

So basically code will look something like this.

If you want to catch keypress event in whole web page, you can simply use:

JQuery keypress enter example:

Output:

Live demo: jQuery keypress enter example

Add Comment