Reputation: 9361
I currently have a table which only has a single editable column. I have a jQCuery change() event associated with the column's input controls to prevent any non numeric keys being pressed, other than tab / delete / backspace.
I would like to replace the Enter key with a Tab press.
Can someone please show me the relevant statement to replace the keyCode based on the Enter character being intercepted?
Upvotes: 1
Views: 1314
Reputation: 38503
Since you are capturing the key's anyway, why not just move focus when the enter key is used rather than try to change keystrokes.
Upvotes: 0
Reputation: 630429
You can't replace it, but you can handle it, like this:
$(".myField").keyup(function(e) {
if(e.keyCode == 13) {
$(this).closest("tr").next("tr").find("input").focus();
return false;
}
});
Just modify the $(this).closest("tr").next("tr").find("input").focus();
(currently going to the next row) portion to whatever your layout is, to find the next element you want to move to and focus it.
Upvotes: 2