PhoneGap catch 'Go' pressed event for iPhone

天大地大妈咪最大 提交于 2019-12-22 10:56:28

问题


I want to know how to catch 'Go' pressed event using PhoneGap.

I have a form with 2 input fields. How do I catch when user has pressed "Go" in keyboard. I tried butting the input fields in a Form and added a onSubmit method. And in my Js I have the method.

function onLoginSubmit(e){
   console.log('submit pressed');
   e.preventDefault();
}

But looks like the method is never called. What is the best way of doing it? An example would be great.


回答1:


try following code:

<head>
<script  language="javascript">
function show()
{
  if(window.event.keyCode == 13)
   {
     alert(window.event.keyCode);
   }
}
</script></head>
<body>
<input  type="text" name="textfields" onKeyPress="show();">
</body>


来源:https://stackoverflow.com/questions/9502561/phonegap-catch-go-pressed-event-for-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!