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.
source share