Skip to content

Instantly share code, notes, and snippets.

@leobalter
Created November 3, 2011 14:02
Show Gist options
  • Save leobalter/1336552 to your computer and use it in GitHub Desktop.
Save leobalter/1336552 to your computer and use it in GitHub Desktop.
Konami Code + Unicorns
var konami = {};
konami.keys = [];
konami.string = '38,38,40,40,37,39,37,39,66,65';
konami.check = function(e) {
konami.keys.push(e.keyCode);
// no memory abuses
if (konami.keys.length > 10) {
konami.keys.shift();
}
if (konami.keys.toString().indexOf(konami.string) >= 0){
$(document).unbind('keydown', konami.check);
konami.callback();
}
};
// change this function content if you want anything else than unicorns
// but, really?! What would you want but unicorns!
konami.callback = function() {
$.getScript('http://www.cornify.com/js/cornify.js',function(){
cornify_add();
$(document).bind('keydown', cornify_add);
});
};
// all set, start it
$(document).bind('keydown', konami.check);
(function(a){var b={};b.keys=[],b.string="38,38,40,40,37,39,37,39,66,65",b.check=function(c){b.keys.push(c.keyCode),b.keys.length>10&&b.keys.shift(),b.keys.toString().indexOf(b.string)>=0&&(a(document).unbind("keydown",b.check),b.callback())},b.callback=function(){a.getScript("http://www.cornify.com/js/cornify.js",function(){cornify_add(),a(document).bind("keydown",cornify_add)})},a(document).bind("keydown",b.check)})(jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment