Reputation: 1693
I'm wondering how e.g. this website did the following 'easter egg':
When you type 'dance' on your keyboard on this page: http://wistia.com/about/yearbook the images change to people dancing.
How could I implement something similar? E.g.
$('#image').bind('keypress', function(e) {
if(e.keyCode==70){
// pressed 'f', do something...
}
});
Upvotes: 0
Views: 87
Reputation:
Just append the input to a string, and check to verify that the last bit of the input = the characters you are looking for.
var secret = "6865786769"; //dance
var input = "";
$(document).keyup(function(e) {
input += e.which;
check_input();
});
function check_input() {
if(input.substr(input.length-secret.length) == secret) {
//the secret code
alert('Dance');
}
}
Here is a working jsfiddle.
Upvotes: 1