Author:Kostas Sp Published On:November 10, 2014 Under:Jquery
In this post I will explain how to easily detect Enter key in Jquery.
In order to detect Enter key in Jquery I assume that you already have a textbox element with id = findbyName in your HTML code.
So when pressing ‘Return-Enter’ on search key input field the your_code_here() function
will be executed.
$('#findbyName').keypress(function(e){ if(e.which == 13) { your_code_here(); e.preventDefault(); return false; } }); |
I presume that the your_code_here(); function will take the contents of the textbox #findbyName
and will feed a search function with what you typed in the textbox.