iPhone的PhoneGap catch'Go'按下事件 [英] PhoneGap catch 'Go' pressed event for iPhone

查看:108
本文介绍了iPhone的PhoneGap catch'Go'按下事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用PhoneGap捕捉Go按下的事件。

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

我有一个包含2个输入字段的表单。当用户在键盘上按下Go时,如何捕获。我尝试在表单中添加输入字段,并添加了 onSubmit 方法。在我的Js我有方法。

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.

推荐答案

请尝试下列代码:

<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>

这篇关于iPhone的PhoneGap catch'Go'按下事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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