admin管理员组文章数量:1330677
I have issue with phonegap on android, i have a simple html
<form>
<fieldset>
<label for="target">Type Something:</label>
<input id="target" type="text">
</fieldset>
</form>
and a simple javascript
$("#target").on("keypress", function(event){
alert(event.which);
});
When i press enter key, nothing happen, other keys work. I use phonegap 2.9.0 and android 2.3.5
Please help me
I have issue with phonegap on android, i have a simple html
<form>
<fieldset>
<label for="target">Type Something:</label>
<input id="target" type="text">
</fieldset>
</form>
and a simple javascript
$("#target").on("keypress", function(event){
alert(event.which);
});
When i press enter key, nothing happen, other keys work. I use phonegap 2.9.0 and android 2.3.5
Please help me
Share Improve this question asked Sep 30, 2013 at 15:03 Anh HậuAnh Hậu 911 silver badge11 bronze badges 02 Answers
Reset to default 5You can use the keycodes to detect which key was pressed. I have an example here:
jsFiddle
HTML
<form>
<fieldset>
<label for="target">Type Something:</label>
<input id="target" type="text" />
</fieldset>
</form>
JavaScript
$("#target").on("keypress", function(event){
if (event.keyCode === 13) {
alert("The enter key was pressed");
event.preventDefault();
}
});
This is how I did it in my mobile app but was not with phonegap so not positive it will work, But worth a try.
$('#target').submit(function (event) {
event.preventDefault();
alert(event.which);
}
本文标签: javascriptPhoneGapAndroid How to detect enter keyStack Overflow
版权声明:本文标题:javascript - [PhoneGap][Android] How to detect enter key - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742259978a2442333.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论