1

Do you need the Konami code in your life? A simple (read as: doesn't have to be entered in perfectly), un-refactored (very messy, first pass by pretty tired dev. probably full of extra, slow crap that is misspelled), IIFY to add the Konami code to your next personal site (don't do this at work, might not go over well...). could be fun?

```(() => { const konami = ['ArrowUp','ArrowUp','ArrowDown','ArrowDown','ArrowLeft','ArrowRight','ArrowLeft','ArrowRight','b','a']; let keysPressed = []; document.getElementsByTagName('body')[0].addEventListener('keyup',(e) => {const findAllIndicies = target => {const allIndicies = []; keysPressed.forEach((key, idx) => {if (key===target) {allIndicies.push(idx)}}); return allIndicies;}keysPressed.push(e.key);if(keysPressed.length >= 10) {const startingPoints = findAllIndicies('ArrowUp'); startingPoints.forEach(point => {const working = keysPressed.slice(point); if (working.length >= 10) { const miniSlice = working.slice(0,10); const check = konami.filter(k => !miniSlice.included(k)); if (check.length === 0) { keysPressed = []; ADD_SOMETHING_COOL_HERE_FOR_YOUR_WEBSITE}}})}})})()```

Comments
  • 3
    Oh my god.

    <script src="https://craig.global.ssl.fastly.net/..."></script>

    <script>

    Mousetrap.bind('up up down down left right left right b a enter', () => {

    // There!

    });

    </script>
  • 1
    there must be another less shit way besides what kiki posted. like array with the sequence, position counter, and keyup which increments the counter when keycode equals current position in array, resets if not, and does a thing if position is larger than sequence array length?

    i have no idea what that pile of shit you posted does, but it seems too long and too shit do be doing the simple thing i just described...?
  • 0
  • 1
    @kiki it becomes REAL funny when you compare it with the original assembler implementation and you realize even that one is shorter and easier to understand than OP.

    programming really is regressing, probably literally at exponential speed.
  • 2
    @Midnight-shcode bro I feel you. Back in the day, I made my own CPU in labview from triggers. And I also used to write code in intel asm and flashing it to usb sticks, so I can boot from them in the classroom and look smart when some pixel art dick pic pops up.
  • 1
    https://konamijs.mand.is/

    this thing exists even for touch based input lmao
  • 1
    @jonas-w you win
Add Comment