how to track two keyboard key when they are down at same time
think user pressed two keys at same time .
I want to b开发者_StackOverflowe notified of this two keys , not one .
like Up + Left
how can I find out this ?
you should register handlers for the keyup and keydown events.
for each key involved in your key combination, you store a flag which tells if the key is up or down. each time you receive a keydown event for one of those keys, you set the flags, each time you receive a keyup event, you reset the flag (set it back to 0).
when all the flags are set, it means that all the keys for the combination are pressed at the same time, you can then call a function of your choice to react on this event.
精彩评论