I am creating an Android application using Cordova/PhoneGap 2.5.0, Knockout 2.1.0 and jQuery Mobile 1.3.0.
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?