diff options
Diffstat (limited to 'js/oops.js')
| -rw-r--r-- | js/oops.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/js/oops.js b/js/oops.js new file mode 100644 index 0000000..1c5a3fc --- /dev/null +++ b/js/oops.js @@ -0,0 +1,38 @@ +// A key map of allowed keys +var allowedKeys = { + 8: 'backspace' +}; + +// The sequence +var oopsCode = ['backspace']; + +// A variable to remember the 'position' the user has reached so far. +var oopsCodePosition = 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 oops Code + var requiredKey = oopsCode[oopsCodePosition]; + + // Compare the key with the required key + if (key == requiredKey) { + + // Move to the next key in the oops Code sequence + oopsCodePosition++; + + // Ff the last key is reached, activate cheats + if (oopsCodePosition == oopsCode.length) { + activateCheats(); + oopsCodePosition = 0; + } + } else { + oopsCodePosition = 0; + } +}); + +function activateCheats() { + + window.location.href = "/oops.html"; +}
\ No newline at end of file |