How to check if enter key pressed in jquery

In a user specific designed application or website, we want application start taking action without user click extra button. Especially in the scenario of search function. You want user be able to start searching when enter key is pressed on the textbox.

<input type="text" id="search" />
$('#search').keypress(function(e) {
    var keyCode = (e.keyCode ? e.keyCode : e.which);
    if(keyCode  == 13) {
        alert('Enter key pressed');