Javascript输入按键事件可用于移动网站 [英] Javascript enter key pressed event alternative for mobile site

查看:64
本文介绍了Javascript输入按键事件可用于移动网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站中有一个快速反馈窗口小部件,其中只有一个文本框.当用户按Enter键时,将使用ajax自动发送反馈.但这不适用于android,j2me等移动设备.有台式机和移动机都可以使用的替代方法吗?我不接受添加提交按钮.

I have a quickfeedback widget in my site which has only one textbox. When user presses enter key, the feedback is automatically sent using ajax. But this doesn't work in mobile devices like android, j2me and so on. Is there any alternative that works in both desktop and mobile? Adding a submit button is not acceptable for me.

推荐答案

我刚刚在android上进行了检查,当您键入内容并按"Go"(输入替代项)时,它将触发一个事件,并且键码实际上为13,因此与在台式机键盘上输入Enter相同.

I just checked on android, when you type something and press "Go" (enter alternative?) it will trigger an event and the key code is actually 13 so the same as Enter on desktop keyboards.

我建议调试代码并检查是否实际触发了提交,但是密钥代码可能并不总是13个吗?只是猜测.

I'd suggest debugging the code and checking whether the submit is actually triggered but maybe the key code isn't always 13? Just guessing..

Edit2:

在您的手机上测试此代码.当我按执行"时,输入值将更改为已发送!".证明它有效.

Test this code on your mobile. When I press "Go" the input value changes to "sent!" which proves that it works.

这篇关于Javascript输入按键事件可用于移动网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆