Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top