Today I am not coming to you with a sob story about vendors or vulnerabilities. At my current company, I develop and maintain one of our testing tools. The tool is a web application that is used hundreds of times a day by several different teams, and is actually called “TestTools” because of its prominence. A few weeks ago I was making some changes to the tool in preparation for some new projects coming up, and while discussing the changes, my co-worker mentioned the Konami Code. So I wondered, how easy would it be do implement the Konami Code into the tool?
Now, I don’t know if I implemented this with best practices or in the “correct” way, but it works and that’s what matters (see: MVP). For this code to work, you will have to include a reference to jquery on your page before this code. This was tested with jquery-1.11.1.min.js, but let me know if you have issues or success with other versions as well!
var step = 0; var code = [38,38,40,40,37,39,37,39,66,65]; $(document).keydown(function(e) { if (e.which === code[step]) step++; else step = 0; if (step === 10) doSurprise(); //e.preventDefault(); // prevent the default action (scroll / move caret) }); function doSurprise() { alert("You found the cheat code! Replace this with your own code on your own site."); }
Update: VanillaJS version:
var step = 0; var code = [38,38,40,40,37,39,37,39,66,65]; document.onkeydown = function(e) { e = e || window.event; if (e.which === code[step] || e.keyCode === code[step]) step++; else step = 0; if (step === 10) doSurprise(); //e.preventDefault(); // prevent the default action (scroll / move caret) }; function doSurprise() { alert("You found the cheat code! Replace this with your own code on your own site."); }
Now, if anyone enters the Konami Code on our test tool site, they get a nice surprise! In our case, it is not the alert() seen above, but a download of a reskinned BonziBuddy, modified to say things specific to our company…
Note: the base of the code above was taken from this stackoverflow answer. Also note: The code in the top image was a first draft, the code in the post is a much better looking alternative!
Nice to see you’re still using my seagull photo as your wallpaper. It’s like I’m still there, in a way.
LikeLike
Haha yes, for sure. It is a nice background.
LikeLike