A neat little snippet which detects when a user has pressed "Enter" on the keyboard.
$('#id_query').keypress(function(e) {
var key = (e.keyCode || e.which);
if (key == 13) {
e.preventDefault();
alert("hi!");
}
});
Mainly notes to future-Twig (and for anyone else who may find them useful)
If you've found one or more of my blog posts helpful, why not say thanks by buying me a coffee or beer?
A neat little snippet which detects when a user has pressed "Enter" on the keyboard.
$('#id_query').keypress(function(e) {
var key = (e.keyCode || e.which);
if (key == 13) {
e.preventDefault();
alert("hi!");
}
});