0

This is my script file to show a div on key press. It works on pc:

$(document).on('keypress', function(e) {
    if(e.keyCode === 97) {   //a
        $('.login-box').show();
        $('#intial').hide();
    }
});

but it dos not work on phones as there is on input fields so I cannot open the keyboard. Is there any way i could go about doing this?.. preferably a touch event (pattern)..

lorond
  • 3,856
  • 2
  • 37
  • 52
Reuben Gomes
  • 878
  • 9
  • 16

1 Answers1

1

You may want to try the keyup or keydown event.

I believe the keypress was deprecated and won't work in this situation.

$(document).on('keyup', function () {
    if(e.keyCode === 97) {   //a
        $('.login-box').show();
        $('#intial').hide();
    }
});
goartex
  • 55
  • 5