From 611180fcf841b89e070f64a47a716536372b9644 Mon Sep 17 00:00:00 2001 From: Matt Lane Date: Wed, 24 Feb 2016 19:49:37 -0800 Subject: [PATCH] add bonus solution --- app.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 4b301a0..8d24a7e 100644 --- a/app.js +++ b/app.js @@ -45,6 +45,20 @@ var noDigits = function(e) { } }; +var idx = 0; + +var konamiCheck = function(e) { + var konamiCodeKeyCodes = [38,38,40,40,37,39,37,39,66,65]; + if (e.keyCode === konamiCodeKeyCodes[idx]) { + idx++; + if (idx === konamiCodeKeyCodes.length) { + alert("YOU ARE AN EVENT HANDLER GURUUUUUUUUU!"); + } + } else { + idx = 0; + } +}; + var initialize = function(){ changeGreetingAndAddGif(); styleListElements(); @@ -52,7 +66,8 @@ var initialize = function(){ document.querySelector("#ghosting").addEventListener("mouseover", function() { this.remove(); }); document.querySelector("#resize").addEventListener("mouseenter", doubleWidth); document.querySelector("#resize").addEventListener("mouseleave", resetWidth); - document.querySelector("body").addEventListener("keypress", noDigits); + document.querySelector("body").addEventListener("keyup", noDigits); + document.querySelector("body").addEventListener("keyup", konamiCheck); }; window.onload=initialize; \ No newline at end of file