Reputation: 878
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
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