I am new to javascript; thus, it question may seem to be naive. I have a simple jQuery function as
$(document).ready(function(){
$('#txtValue').keyup(function(){
sendValue($(this).val());
});
});
This sends immediately when a letter is typed in
I explored jQuery events, but I was unable to find an event for ENTER. I want to run the function when I typed all letters and pressed ENTER.
Check the
keyCodeproperty of the event object. 13 represents the Enter key:The
keyupevent will fire every time a key is released. There is no way to selectively fire the event, but you can choose when to handle it!Edit
It’s actually better to use
event.which, to deal with all browsers, as jQuery normalises the event object to help.