I would like to be able to log the key presses on a specific page, trying to implement an ‘Easter egg’ type functionality where when the correct keys are pressed in the correct order it triggers and event.
Can anyone give me any pointers?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, even though another answer has been accepted, I’m going to throw one out there anyway.
When you ultimately type ‘egg’ (for this example), you will get an alert, and the key history will reset.
EDIT: Updated the code to truncate the string if it gets too long.