Konami Code Plugin

I have made a working plugin for the Konami Code that you can activate at anytime during gameplay, this to activate a control switch (by default Switch 3, because that's what I needed it for). Use it for whatever, doesn't matter.

It is free for anyone to use, commercial or otherwise. No restrictions.

Up, up, down, down, left, right, left, right, B, A (X, Z on keyboard).

Download it here


JavaScript:
/*:
 * @plugindesc Triggers a control switch (Switch 3) when the Konami Code is entered at any time.
 * @thenbexperience
 *
 * @help
 * This plugin triggers Switch 3 when the Konami Code is entered:
 * Up, Up, Down, Down, Left, Right, Left, Right, B, A
 */

(function() {
    const switchId = 3; // Switch ID to be activated

    const konamiCode = [
        38, 38, // Up, Up
        40, 40, // Down, Down
        37, 39, // Left, Right
        37, 39, // Left, Right
        88, 90  // B, A (X, Z in RPG Maker MV)
    ];

    let inputSequence = [];

    const checkKonamiCode = () => {
        if (inputSequence.length === konamiCode.length) {
            if (JSON.stringify(inputSequence) === JSON.stringify(konamiCode)) {
                $gameSwitches.setValue(switchId, true);
                console.log('Konami Code entered! Switch ' + switchId + ' is now ON.');
                inputSequence = []; // Reset the input sequence
            }
        }
    };

    const inputHandler = (event) => {
        inputSequence.push(event.keyCode);
        if (inputSequence.length > konamiCode.length) {
            inputSequence.shift(); // Keep only the last N inputs
        }
        checkKonamiCode();
    };

    // Add the event listener for keydown
    document.addEventListener('keydown', inputHandler);
})();
@thenbexperience Hi there! What are the terms of use?
Hi there @thenbexperience wondering if you saw the previous message? We can hold on to this for only another 48 hours. Thank you!
Hi there @thenbexperience wondering if you saw the previous message? We can hold on to this for only another 48 hours. Thank you!
Sorry I just saw this. It is free for anyone to use, commercial or otherwise. No restrictions.
Looks like fun! Would be nice if this could be expanded to accept any/multiple codes and at specific places. (Like menu only or title screen only)
It could do different imports, if the button codes were changed. I may try to implement those suggestions once I am done with my project. I basically created this specifically for that type of usage case, but those are great ideas. I will try to add those once I am done!
Looks like fun! Would be nice if this could be expanded to accept any/multiple codes and at specific places. (Like menu only or title screen only)
I probably would do it through Scene_Map as I built something like
this through a struct and a prompt to add codes.

the way you do could be around the same way, but around checking
the update and delay.

if not complete, cancel all or only during specifics maps.
but as it can unlock something if doing it nicely though if it's done invisible.

Original thread: https://forums.rpgmakerweb.com/threads/konami-code-plugin.172202/