在 android-webview 中的 android 键盘中输入键也不适用于 JavaScript 中的输入
我的 html 表单标签内有输入类型文本。当我按下移动设备的 Enter 键时,JavaScript 的按键事件未执行。在电脑键盘上它工作正常。当我将此输入不在表单标签内时,它在移动设备中工作正常。 我尝试了按键、按键按下、按键按下事件。
$("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;
}
}
})
注意:此输入位于一个 div 下,并且在执行某些事件时重写整个 html。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论