I'm making a crossword application using PhoneGap, and need to detect if the user has just done a quick press on the keyboard or has held down a key to get a special character. What would be the event to detect this?
EDIT: When I press the button and don't release it, then keyup is triggered before I release the key. IPhone doesn't have this problem, and the emulator with SDK 8 version doesn't have this issue too. The HTC Desire S and possibly other HTC phones may have this 'feature'. Looks lika a bug to me.
try this if you want to know at any moment which keys are pressed:
var keys = array();
$(windows).keydown(function(e){
keys[e.which] = true;
}
$(windows).keyup(function(e){
keys[e.which] = false;
}
If you just want to trigger an action when a user press a key for a while, just set a timeout which you can cancel if keyup is triggered before the desired time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With