Detecting enter key was pressed using JQuery

Last updated:

If you have a Text Input whose ID is my-input, this is the JQuery code you need to make it listen to the Enter key being pressed:

$('#my-input').keypress(function(e){
    if(e.which == 13){
        //do some action 
    }
});

TECHNOLOGY
jquery

Dialogue & Discussion