<script type="text/javascript">
if ( window.addEventListener ) {
var state = 0, konami = [38,38,40,40,37,39,37,39,66,65];
window.addEventListener("keydown", function(e) {
if ( e.keyCode == konami[state] ) state++;
else state = 0;
if ( state == 10 )
alert("You have entered the KONAMI CODE! You now have 30 lives. Kinda.")
}, true);
}
</script>
Yepp. That's right.
You press Up Up Down Down Left Right Left Right A B on your keyboard (aka, the Konami Code (or Contra Code)) and there's a message box that says that.
Well. I'd rather it do something fancier.
Such music playing... (http://outlawperformance.com/ or http://geek.thinkunique.org/) (Perform the Konami Code)
If you have any ideas and can provide working codes (or can show me how to do the music one) please let me know.
This would be wonderful.
The codes I looked for playing music seemed way to complicated for me, and frankly, I can't read javascript...
Last edited by JpsCrazy on January 21st, 2011, 7:57 am, edited 1 time in total.
The part you're going to want to change is the line that says: alert("You have entered the KONAMI CODE! You now have 30 lives. Kinda."). Ideally you would replace that with a call to another function that would do the whole "playing music" bit. Both of the site you link to actually load a separate page that has music set to play.
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var bShowing=false;
function showKonami() {
if(bShowing) return;
var oFrame = isInternetExplorer ? document.all.konami : document.getElementById('konami');
oFrame.setAttribute('height',30);
oFrame.contentWindow.location.replace("http://geek.thinkunique.org/wp-content/themes/blue-pix/music.html");
bShowing=true;
}
Replace the URL there with the one to whatever page you will use. For them, the page is simply a flash-based music player that starts as soon as the page is loaded. Then all you need to do is call that function instead of the alert in the listener.