This site requires JavaScript, please enable it in your browser!
Greenfoot back
lava1234567890
lava1234567890 wrote ...

2015/9/20

Track key presses?

lava1234567890 lava1234567890

2015/9/20

#
I want to track key presses so I can trigger an Easter egg when they are pressed in the right order. How would I be able to do this?
danpost danpost

2015/9/21

#
Define a String field to hold the keystrokes. Initialize its value to an empty string and reset it to an empty string anytime the order is tested and found incorrect. Each time a key is pressed, add that character to the string. You will have to decide when to check the concatenated string for the proper sequence and when to clear its value.
You need to login to post a reply.