简体   繁体   English

在移动模式下如何处理按键事件。 当在输入类型=“文本”上按下键时..在桌面模式下正常工作(通过键盘按下键)

[英]how to handle on key press event on mobile mode . when key press on input type=“text”.. its work proper on desktop mode (key press by keyboard)

How to on keypress event of javascript handle the validation of vechicle number in mobile mode .. not work properly. 如何在JavaScript的按键事件上处理移动模式下车辆编号的验证..无法正常工作。

<input type="text" onkeypress="func1()" id="vname">
<script>
function func1()
{
alert('hello');
}
</script>

<input type="text" onkeypress="func1()" id="vname">

not alert the message on keypress of id="vname" in mobile but work proper in desktop mode ... and i also try the tap () of jquery mobile but its also not works when touch the keyboard through enter the value in input tag 不会在移动设备上按下id =“ vname”的键时提醒消息,但在桌面模式下可以正常工作...并且我也尝试使用jquery mobile的tap(),但通过在输入标签中输入值触摸键盘时也无法使用

keypress is known to be troublesome in mobile environments. 众所周知, keypress在移动环境中很麻烦。 You should use onkeydown 您应该使用onkeydown

<input type="text" onkeydown="func1()" id="vname">
<script>
function func1()
{
alert('hello');
}
</script>

<input type="text" onkeydown="func1()" id="vname">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM