Adam K Dean

Detect enter key hit using jQuery

Published on 3 July 2013 at 14:33 by Adam

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');
});

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



This post was first published on 3 July 2013 at 14:33. It was filed under archive with tags jquery, javascript.