Detect enter key hit using jQuery

Adam K Dean - Jul 3 '13 - - Dev Community

Just a little snippet today, for future reference more than anything.

$('.textbox').bind('onEnter', function(e) { 
    // your code here
});
$('.textbox').keyup(function(e) {
    if (e.keyCode == 13) 
        $(this).trigger('onEnter');
});
Enter fullscreen mode Exit fullscreen mode

It's pretty much self-explanatory. When enter is pressed, the above function fires.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player