On the window
I bind two keydown
events. The condition for triggering a callback function is a certain sequence:
Event #1: ["down", "right", "a"]
Event #2: ["down", "right", "down", "right", "a"]
How can I check if the user pressed the event 2 keys and then cancel the event 1?
Here is the code, focus on the red div and press the keys ▼ ► ▼ ► A, you will see the two events triggering. I need to know how can I check if a more precise one have been triggered...
To check if the sequence is right I compare the sequence with the end of the user input.