Skip to content

Instantly share code, notes, and snippets.

@jadwigo
Created August 18, 2015 12:27
Show Gist options
  • Save jadwigo/0bed8ed97bd0874d37e8 to your computer and use it in GitHub Desktop.
Save jadwigo/0bed8ed97bd0874d37e8 to your computer and use it in GitHub Desktop.
How to add a konamicode to your jqueries
// Konami code block
jQuery(function( $ ){
if ( window.addEventListener ) {
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
window.addEventListener("keydown", function(e){
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ) {
console.log('> Someone entered Konami Code. Quickly, do something cool!')
console.log('< Do something cool?');
console.log('> Yes!, Quickly!');
console.log('< Sorry, do you have any ideas?');
console.log('> Make the print page a treasure map!');
console.log('< Sorry, we tried that, but then the print page changed a little, so it broke');
console.log('> Aw really?');
console.log('< Yup.. maybe later we will fix it, but at the moment it does not work.. sorry.');
// do something here
kkeys = [];
}
}, true);
}
});
// end Konami code block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment