1

I have a code which works really well in desktop, but not in mobile, i need to solve it. Here is my javascript code:

function O000OOO(e) {
var O0000O0;
if (window.event) {
    if (window.event.type == "keypress") {
        O00OO00 = -1
    }
    if (window.event.type == "keypress") {
        O00OO00 = window.event.keyCode
    }
    if (parseInt(O00OO00) > 0) {
        O0000O0 = O00OO00
    } else {
        O0000O0 = window.event.keyCode
    }
} else {
    if (e.type == "keypress") {
        O00O0OO = e.which;
        O00OO00 = -1
    }
    if (e.type == "keypress") {
        O00OO00 = e.which
    }
    if (parseInt(O00OO00) > 0) {
        O0000O0 = O00OO00
    } else {
        if ((parseInt(O00O0OO) > 0) && (e.which < 1)) {
            O0000O0 = O00O0OO
        } else {
            O0000O0 = e.which
        }
    }
}
return (parseInt(O0000O0))

}

Can anyone tell me, how to make it work in mobile too. When i type in my pc it works, but not in phone, why? How can i fix it?

2 Answers2

2

You've tagged this with jquery-mobile, so it looks as if you can use jQuery. In that case, you can use keyup instead of keypress, which preferable. It reduces the chance that the input can be repeated if the key is held too long.

Kinna T
  • 762
  • 5
  • 12
0

you can try input instead of keypress.

Nehal
  • 13,130
  • 4
  • 43
  • 59