在 android-webview 中的 android 键盘中输入键也不适用于 JavaScript 中的输入

发布于 2025-01-09 12:54:20 字数 1217 浏览 3 评论 0原文

我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文