Last active
July 19, 2017 18:49
-
-
Save jacquerie/8630208 to your computer and use it in GitHub Desktop.
Adds a Konami Code easter egg to a page. Requires jQuery.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var addkonamiCode = function () { | |
var status = 0; | |
$("body").keydown(function (e) { | |
if ((e.which === 38 && (status === 0 || status === 1)) | |
|| (e.which === 40 && (status === 2 || status === 3)) | |
|| (e.which === 37 && (status === 4 || status === 6)) | |
|| (e.which === 39 && (status === 5 || status === 7)) | |
|| (e.which === 66 && status === 8)) { | |
status++; | |
} else if (e.which === 65 && status === 9) { | |
$(body).append("<div class=nyanCat></div>"); | |
$(".nyanCat").fadeOut({ | |
complete: function () { $(this).remove(); }, | |
duration: 2500 | |
}); | |
status = 0; | |
} else { | |
status = 0; | |
} | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.nyanCat { | |
display: block; | |
position: fixed; | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
margin: auto; | |
width: 301px; | |
height: 119px; | |
background: url("img/nyan.gif"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment