I have input type text in my html inside form tag. Key down event of JavaScript is not executing when I press enter key of mobile devices. In computer keyboard it’s working fine. When I put this input not inside form tag it’s working fine in mobile devices.
I tried keypress, key down, key up events.
$("body").on("keydown", "input, select, textarea, button", function(e) {
var self = $(this),
form = self.parents("form:eq(0)"),
focusable,
next,
id;
id = $(this).closest("tr").parent().parent().attr("id");
if (
e.keyCode == 13 ||
e.keyCode == 9 ||
e.key == "Next" ||
e.key == "Go"
) {
focusable = form
.find('input[type!="checkbox"],a,select,button,textarea')
.filter(":visible:not([readonly]):enabled");
if (
(this.type == "text" ||
this.type == "tel" ||
this.type == "email" ||
this.type == "time" ||
this.type == "select-one" ||
this.type == "number" ||
this.type == "date") &&
$(this).attr("tabindex") < 700
) {
previous_elem = $(this);
valid_func_agets(this, e);
return false;
}
}
})
Note:this inputs is under one div and am rewriting entire html when some events executes.