2012-11-10, 04:29 AM
Introduction
The Konami Code, used in many Konami Video Games, is a series of keystrokes which, when triggered, cause an Easter Egg. The keystrokes are up, up, down, down, left, right, left, right, B, A, Enter. Today, I'll be showing you how to implement this in your website using only one template edit. Best of all, it only uses JavaScript. Let's begin.
Open headerinclude. Insert at the bottom:
The key points here are:
"konami" is your Konami Code. To anyone, it's a string of meaningless numbers. But to you and I educated webmasters, they're the required keystrokes.
"alert("lulz");" is what happens when the Konami Code is triggered. So here, it causes an alert box to pop up saying "lulz".
Let's say you have Pirata's NewPoints and CouponCodes installed and wanted it so that, if the User decided to use the Konami Code, it'd send them to the Coupon Code page. You'd change our alert box to:
So your code would be:
Voila, Konami Code implemented!
Who would use it?
Two word: Gaming Sites. I mean, you tell them about the Easter Egg, so why don't you demo it for them?
The Konami Code, used in many Konami Video Games, is a series of keystrokes which, when triggered, cause an Easter Egg. The keystrokes are up, up, down, down, left, right, left, right, B, A, Enter. Today, I'll be showing you how to implement this in your website using only one template edit. Best of all, it only uses JavaScript. Let's begin.
Open headerinclude. Insert at the bottom:
<script type="text/javascript">
if (window.addEventListener) {
var keys = [],
konami = "38,38,40,40,37,39,37,39,66,65";
window.addEventListener("keydown", function(e){
keys.push(e.keyCode);
if (keys.toString().indexOf(konami) >= 0) {
alert("lulz");
keys = [];
};
}, true);
};
</script>
The key points here are:
konami = "38,38,40,40,37,39,37,39,66,65";
alert("lulz");
"konami" is your Konami Code. To anyone, it's a string of meaningless numbers. But to you and I educated webmasters, they're the required keystrokes.
"alert("lulz");" is what happens when the Konami Code is triggered. So here, it causes an alert box to pop up saying "lulz".
Let's say you have Pirata's NewPoints and CouponCodes installed and wanted it so that, if the User decided to use the Konami Code, it'd send them to the Coupon Code page. You'd change our alert box to:
window.location = '{$mybb->settings['bburl']}/couponcodes.php';
So your code would be:
<script type="text/javascript">
if (window.addEventListener) {
var keys = [],
konami = "38,38,40,40,37,39,37,39,66,65";
window.addEventListener("keydown", function(e){
keys.push(e.keyCode);
if (keys.toString().indexOf(konami) >= 0) {
window.location = '{$mybb->settings['bburl']}/couponcodes.php';
keys = [];
};
}, true);
};
</script>
Voila, Konami Code implemented!
Who would use it?
Two word: Gaming Sites. I mean, you tell them about the Easter Egg, so why don't you demo it for them?