HTML Input box to fire off some Javascript when the enter key is pressed
Just some simple jQuery code to wire up the 'enter' key on a textbox, which then does some javascript (like an AJAX call to a server).
<input type="text" id="textbox-query" />
$('#textbox-query').keypress(function (e) {
if (e.which == 13) {
doSomething(..);
return false;
}
return true;
});Written by Pure Krome
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#