Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
86
rated 0 times [  90] [ 4]  / answers: 1 / hits: 33320  / 12 Years ago, fri, march 30, 2012, 12:00:00

I have defined keyboard events which is working good in desktop but for touch devices not getting the onscreen keyboard event. I need to capture if user is typing. I have used the following segment of code :



$('#id').keydown(function(e){
//some code here
});

$('#id').keyup(function(e){
//some code here
})


I want the code defined in keydown and keyup to trigger even for touch devices (both tablets and mobiles). Please suggest how to capture the onscreen keyboard event and make the above code to run.


More From » jquery

 Answers
22

Have you tried using key press instead of key down



$(#id).keypress(function() {

});


Updated :



Due to android problems I now normally wrap my checks like this



if ($.browser.mozilla) {
$(#id).keypress (keyPress);
} else {
$(#id).keydown (keyPress);
}

function keyPress(e){
doSomething;
}

[#86516] Thursday, March 29, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zainsagez

Total Points: 555
Total Questions: 99
Total Answers: 96

Location: Honduras
Member since Sat, Jul 24, 2021
3 Years ago
;