We use this code for simulating Tab key with Enter key:
function EnterTab() {
if (event.keyCode == 13) event.keyCode = 9;
retur
We use this code for simulating Tab key with Enter key:
...
When I hit Enter I want focus go to next control.
The idea is wrong. Don't change enter to tab. Tackle this problem by intercepting the enter key, set the focus on next element and cancel the event. jQuery solution:
$(function() {
$("form").on("keypress", "input[type=text], select, textarea", function(e) {
if (e.which === 13) {
e.preventDefault();
var $fields = $(this).closest("form").find(":input");
var index = $fields.index(this);
$fields.eq(index + 1).trigger("focus");
}
});
});
input,
select,
textarea {
box-sizing: border-box;
margin: .5em 0;
width: 100%;
}
jsFiddle for testing in Internet Explorer