I am working on converting a web app to Android app using Phonegap. keypress event is not firing when I press a key on keyboard. I noticed that keydown event is fired instead of keypress but with keyCode and charCode always 0. Please help.
My code is:
if (document.addEventListener){
console.log("****** document.addEventListener ******");
document.addEventListener("keydown",UI.keydown,false);
document.addEventListener("keypress",UI.keypress,false);
}
else if (document.attachEvent)
{
console.log("****** document.attachEvent ******");
document.attachEvent("onkeydown", UI.keydown);
document.attachEvent("onkeypress", UI.keypress);
}
else
{
console.log("****** document.onkeypress ******");
document.onkeydown= UI.keydown;
document.onkeypress= UI.keypress;
}