1

The code below works fine on a desktop browsers, where I am able to capture each keystroke. However the same code does not capture keystrokes on Android mobile browser. What could be the reason for this behavior? Thanks in advance

<a href="#sphome" id="sphomelink"></a>
<div data-role="page" id="sphome" >
....
<form action="Tokens" method="GET" id="TokenSubmit" >
<input size="10" type="text" name="BToken" id="token">
....
</form>
</div>


$('#token').on('keyup',function(event){
    alert(event.which);
}) 
RajCherla
  • 51
  • 3
  • Possible duplicate of [Jquery keyup not working on Android](http://stackoverflow.com/questions/10580295/jquery-keyup-not-working-on-android) – 4castle Aug 04 '16 at 18:06
  • Thanks. I tried those out before posting. They did not work for me. Is there some possibility that mobile browser is not passing on each keystroke, but the entire input after user's ENTER. I did notice such behavior when I used 'keypress' on mobile instead of 'keyup' – RajCherla Aug 04 '16 at 18:13
  • It may be a bug with the keyboard, there was [this question](http://stackoverflow.com/q/32533480/5743988) – 4castle Aug 04 '16 at 18:14
  • the problem seems to be with the keyboard. I have a Samsung S6, that consistently gives the wrong keyCode (229) for all keys !! Got to find a different workaround for this problem. Thanks 4castle ..the link helped. Thanks @Qsprec – RajCherla Aug 04 '16 at 18:49

1 Answers1

0

Try using document on like;

$(document).on('keyup','#token', function() {
   // code
});

This one should work.

Qsprec
  • 265
  • 3
  • 11
  • I tried this variation too. Did not work, Seems to be some buffering issue, and not the call itself. All the variations work on desktop but not mobile. Just not able to capture keystroke. – RajCherla Aug 04 '16 at 18:14