This question already has an answer here:
<html><input id="test" type="text" /></html>
<script>
$(function(){
$("#test").keypress(function(event)
{
if ((event.charCode == 32) || (event.charCode == 64))
alert("Working with space & @ but not with Enter");
});
});
</script>
Here is my code but it's not working for ascii of 'Enter' which is '13'
</div>
You can use "event.which" instead of "event.charCode" to get the key pressed. event.which will return 13 for enter key pressed.
Example:
var code = event.charCode || event.which;
if(code == 13) { //Enter keycode
//Do something
}