Detect enter key press event in jquery/javascript

The following code will help you get the enter key press event in jquery or javascript :

HTML :

<input type="text" class="search_box" placeholder="Search Here..!!" />

Jquery/Javascript

$('.search_box').keypress(function (event) {
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if (keycode == '13') {
        alert("Enter key pressed");
    }
});

Cheers..

1 Comment on "Detect enter key press event in jquery/javascript"


  1. thank you,
    so in my case, i am using this code

    it is order to show number keypad on tablet but i cannot catch “Go” event
    Can you show me how you can do that.
    Thank you

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *