JQuery Detects Keyboard Key Holds Down

I am doing a crossword puzzle application using PhoneGap, and you need to determine if the user just quickly pressed the keyboard or pressed a key to get a special character. What will be this event?

EDIT: When I press a button and do not release it, the keyboard fires before I release the key. The iPhone does not have this problem, and an emulator with SDK version 8 does not have this problem either. HTC Desire S and possibly other HTC phones may have this β€œfeature.” Looks lika a mistake for me.

+4
source share
2 answers

try this if you want to know at any time which keys will be 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 the user presses a key for a while, just set a timeout that you can cancel if the keyboard activation starts before the desired time.

+2
source

Maybe we'll see if it goes through

another key code
 $('#input').live('keypress',function(e){ console.log('keypress: '+e.keyCode); }); 
0
source

Source: https://habr.com/ru/post/1402439/


All Articles