捕获" Enter]键。关键preSS与Android的数字输入/科尔多瓦/淘汰赛 [英] Capture "Enter" keypress with numeric input in Android/Cordova/Knockout
问题描述
我创建使用科尔多瓦/ PhoneGap的2.5.0,2.1.0淘汰赛和jQuery移动1.3.0 Android应用程序。
I am creating an Android application using Cordova/PhoneGap 2.5.0, Knockout 2.1.0 and jQuery Mobile 1.3.0.
我已经创建了一个输入,类型为数字,该输入它的价值数据绑定与淘汰赛。这也是数据绑定到一个关键的preSS事件。我打算抓住用户pressing的<大骨节病>输入骨节病>键。
I have created an input with type "number", this input is databound with Knockout on it's value. It is also databound to a key press event. I'm intending to catch the user pressing the enter key.
<input type="number" data-bind="value: $root.myInputValue, event: { keypress: $root.myInputKeypress }" min="0" step="1" max="29">
self.myInputKeypress = function() {
var keyCode = (event.which ? event.which : event.keyCode);
alert(keyCode);
if (keyCode === 13) {
//Do work here
return false;
}
return true;
};
当我preSS允许的密钥等一批在code运行正常和pressed键code被惊动。当我preSS <大骨节病>输入键盘没有任何反应的,看来Android是由按键认为燮pressing事件是不相关的。
When I press an allowed key such as a number the code runs as expected and the pressed keys code is alerted. When I press enter on the keyboard nothing happens, it seems that Android is suppressing events from keys it thinks are not relevant.
有没有办法来改变这种行为,这样我可以捕捉用户按<大骨节病>输入骨节病>?
Is there a way to change this behaviour so that I can capture the user hitting enter?
推荐答案
我有同样的问题在模拟器,问题出在一些领域的关键code的输入是9我的设备上,这是13
I had the same issue, the problem was with number field the keycode for enter is 9 on my device, on simulator it is 13.
这对我的作品:
$('.ui-input-text').live('keyup', function(event) {
if (event.keyCode == 9) {
// 'Go' pressed do something
}});
这篇关于捕获&QUOT; Enter]键。关键preSS与Android的数字输入/科尔多瓦/淘汰赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!