From c2b8ab67f27f27fe14de6b6ab521ce588106edaa Mon Sep 17 00:00:00 2001 From: zach-m Date: Mon, 10 Apr 2023 18:09:59 -0600 Subject: [PATCH] adding labels --- src/device/input/raw/public/konami.js | 45 +++++++++++++++++++++++++++ src/device/input/raw/public/root.html | 39 ++++++++++++++++------- 2 files changed, 73 insertions(+), 11 deletions(-) create mode 100644 src/device/input/raw/public/konami.js diff --git a/src/device/input/raw/public/konami.js b/src/device/input/raw/public/konami.js new file mode 100644 index 0000000..cfb5cc4 --- /dev/null +++ b/src/device/input/raw/public/konami.js @@ -0,0 +1,45 @@ +// a key map of allowed keys +var allowedKeys = { +37: 'left', +38: 'up', +39: 'right', +40: 'down', +65: 'a', +66: 'b' +}; + +// the 'official' Konami Code sequence +var konamiCode = ['up', 'up', 'down', 'down', 'left', 'right', 'left', 'right', 'b', 'a']; + +// a variable to remember the 'position' the user has reached so far. +var konamiCodePosition = 0; + +// add keydown event listener +document.addEventListener('keydown', function(e) { +// get the value of the key code from the key map +var key = allowedKeys[e.keyCode]; +// get the value of the required key from the konami code +var requiredKey = konamiCode[konamiCodePosition]; + +// compare the key with the required key +if (key == requiredKey) { + + // move to the next key in the konami code sequence + konamiCodePosition++; + + // if the last key is reached, activate cheats + if (konamiCodePosition == konamiCode.length) { + showSecrets(); + konamiCodePosition = 0; + } +} else { + konamiCodePosition = 0; +} +}); + +function showSecrets() { + console.log("Hi") + var element = document.getElementById("konami") + console.log(element) + element.style = "display:block" +} \ No newline at end of file diff --git a/src/device/input/raw/public/root.html b/src/device/input/raw/public/root.html index fb04639..f673c5d 100644 --- a/src/device/input/raw/public/root.html +++ b/src/device/input/raw/public/root.html @@ -2,6 +2,7 @@
+
@@ -74,21 +77,32 @@
- - - - + + + + + + + +
- - - + + + + + +
- - - - + + + + + + + +
@@ -96,6 +110,9 @@
+