jQuery capture ‘Enter’ key in text field

Fiddle
http://jsfiddle.net/pootie/8wGFe/2/

Code

$(document).ready(function() {
    $('#searchBox').keypress(function(event){
        var keycode = (event.keyCode ? event.keyCode : event.which);
        if(keycode == '13'){
            alert('You pressed a "enter" key in textbox');    
        }
    });
}

admin

Chris Tran is a Software Project Manager from Brisbane, Australia. When he's not enjoying time with his family, he works with some very talented people at KoBold Group Pty Ltd.

More Posts

Follow Me:
TwitterFacebookLinkedInGoogle PlusFlickrYouTube

Comments