Reuben Gomes
Reuben Gomes

Reputation: 878

Jquery keypress event on phone

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)..

Upvotes: 0

Views: 3956

Answers (1)

goartex
goartex

Reputation: 55

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();
    }
});

Upvotes: 1

Related Questions