我正在使用 Cordova/PhoneGap 2.5.0、Knockout 2.1.0 和 jQuery Mobile 1.3.0 创建 Android 应用程序。
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;
};
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?
如果您正在使用离子/角
<input ng-keypressed="myKeyPressed($event)" ng-model="myField">
self.myKeyPressed = function(keyEvent) {
if(keyEvent.keyCode == 13) //do things
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)