I have something like this:
$('#find').click(function() {...
I need to also add to that event that if they press the enter key it will also execute.
I was thinking something along the lines of:
var code = (e.keyCode ? e.keyCode : e.which);
if ( ($('#find').click()) || (code == 13)) {
But obviously it does not work. How can I merge both ways into one. Pressing enter should work only when done in the input with id=”code”. The click event is for another input type button with id=”find”. I want to merge both that, if the user presses enter while typing the code or clicking the button to send the code, both ways work the same way.
you can do it like this:
or maybe use keyup, you should read the docs on that: http://api.jquery.com/keyup/