PDA

View Full Version : Konami Code Sites


jdcfsu
2009-05-08, 16:50
Since Gruber posted a link to this site (http://konamicodesites.com/) yesterday, I've been trying to figure out how they do it.

I know nothing about JavaScript, which is what I'm thinking is the brains behind the operation. From what I gather, the JavaScript changes the display:none set on the hidden info and makes it show up. But I can't figure it out. Anyone care to help?

Kickaha
2009-05-08, 16:53
Use the code?

http://en.wikipedia.org/wiki/Konami_Code

jdcfsu
2009-05-08, 21:36
No, I mean, if someone could help me figure out what JavaScript or whatever else is used so that when the code is entered, the site reacts.

Brad
2009-05-08, 21:46
Err, view the source code? It's all right there.

The JQuery site's JavaScript is pretty easy to read. It even has comments. In there I found:
// Hehe.
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 )
window.location = "http://ejohn.org/apps/hero/";
}, true);
}

jdcfsu
2009-05-08, 22:04
Thanks Brad. I was trying to read the source of the base site but it didn't have a 'konami' designation. Now that I know the main string, I can see how it works on other sites. Thanks.

zsummers
2009-05-09, 00:41
I like ponies...

Swox
2009-05-09, 01:11
My brother and I learnt this code playing Ikari Warriors. That game would have been impossible without it...