JavaScript (JQuery)
$('input').keyup(function(e)
{
var code = e.keyCode ? e.keyCode : e.which;
switch(code)
{
case 38:
break;
case 40:
break;
case 13:
break;
default:
return;
}
});
HTML
<form method="post" action="/">
<input type="text" name="text" />
<button type="submit">Submit</button>
</form>
I have 2 problems:
1) The caret shouldn't move when I hit the up arrow key.
For example, in Chrome when I hit the up-key it moves the caret to the left. But I only have this problem in Chrome. It works fine in FF.
2) When I hit the enter key, I don't want the form to be submitted.
BTW, I want to get this to work with keyup and not keypress.
I'd appreciate any ideas. Thanks.