Skip to content

Instantly share code, notes, and snippets.

@fael
Created September 12, 2011 21:10
Show Gist options
  • Save fael/1212446 to your computer and use it in GitHub Desktop.
Save fael/1212446 to your computer and use it in GitHub Desktop.
Javascript Easter Egg - Konami Code
var kkeys = [],
konami = "38,38,40,40,37,39,37,39,66,65";
easterEgg = function (e) {
kkeys.push(e.keyCode);
if (kkeys.toString().indexOf(konami) == 0) {
var ee = $('<div id="ee">TROLOLOL</div>');
ee.css({
padding: '20px',
background: '#FFD100',
color: '#222',
font: 'bold 20px Trebuchet MS, Arial, Verdana',
position: 'fixed',
left: '29%',
top: '39%',
borderRadius: '10px',
display: 'none',
zIndex: '99999',
opacity: '.95',
boxShadow: '#111 0px 2px 16px'
});
ee.wrapInner("<div style='position:relative'></div>");
$('<a id="fechar-ee" href="#" onclick="$(this).parent().fadeOut()">x</a>').css({
position: 'absolute',
right: '5px',
top: '0',
color: '#fff',
fontWeight: 'normal'
}).appendTo(ee);
$('body').append(ee);
$("#ee").fadeIn();
$(window).unbind('keydown', easterEgg);
}
}
$(function () {
$(window).bind('keydown', easterEgg);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment