I was asked to implement the Konami Code in a website I\'m currently working on. It should do the following:
Change Background Image
Play s
I really liked Peter's answer, so I made it namespaced and made the callback optional. I also used jquery because I like it ¯\_(ツ)_/¯
var Konami = Konami || {};
Konami.key = '38384040373937396665';
Konami.onCode = function(callback) {
var input = '';
$(document).on("keydown", function(e) {
input += ("" + e.keyCode);
if (input === Konami.key) {
if(typeof callback == 'undefined') {
return alert("⬆⬆⬇⬇⬅➡⬅➡