Replace function of Menu keys ('X' and 'ESC')

Hey folks!

I've built a new menu system that runs directly within Scene_Map instead of pushing Scene_Menu (so the menu doesn't pause the game).

It all works fine. I have it mapped to "P" on the keyboard at the moment for testing.

But I can't figure out how to disable the old menu system to replace it with the new one... can't see where 'X' is being mapped or how 'ESC' is triggering the menu.

Ideally I'd like to replace the function of 'X' to run my own command instead of bringing up Scene_Menu.

Can anyone point me in the right direction pleeeaassse?
You may find lines 790-801 of rpg_scenes.js helpful:

Code:
Scene_Map.prototype.isMenuCalled = function() {
    return Input.isTriggered('menu') || TouchInput.isCancelled();
};

Scene_Map.prototype.callMenu = function() {
    SoundManager.playOk();
    SceneManager.push(Scene_Menu);
    Window_MenuCommand.initCommandPosition();
    $gameTemp.clearDestination();
    this._mapNameWindow.hide();
    this._waitCount = 2;
};
Not sure if this is helpful or not but you could possibly Use the "Change Menu Access" event trait. I think its in tab 3 of the event commands. If you disable it right away in the game before the player has control it should work. But The other problem of binding it to a new key I'm not sure about, sorry!
You may find lines 790-801 of rpg_scenes.js helpful:

Code:
Scene_Map.prototype.isMenuCalled = function() {
    return Input.isTriggered('menu') || TouchInput.isCancelled();
};

Scene_Map.prototype.callMenu = function() {
    SoundManager.playOk();
    SceneManager.push(Scene_Menu);
    Window_MenuCommand.initCommandPosition();
    $gameTemp.clearDestination();
    this._mapNameWindow.hide();
    this._waitCount = 2;
};

Fab! Thank you. I had a play with that function before, swapping out SceneManager.push(Scene_Menu);

Scene_Map.prototype.callMenu = function() {
SoundManager.playOk();
this.myNewFunction();
Window_MenuCommand.initCommandPosition();
$gameTemp.clearDestination();
this._mapNameWindow.hide();
this._waitCount = 2;
}

But it was popping the Scene_Map for some reason, closing the game.

So scrapped the whole contents and just used:

Scene_Map.prototype.callMenu = function() {
this.myNewFunction();
}

and now it works ^_^ Thank you! Hopefully it doesn't remove anything that'll cause a bug.
Urg, no. Looks like it still pops the scene when the menu is closed... gonna dig deeper.
Aha. duh. I imported this.popScene(); from Scene_Menu's closeCommand();

Also had to change this to return false

Scene_Map.prototype.isMenuCalled = function() {
return false;
};

Now I think it's working.
No, found more bugs. It works when I trigger it from 'P' but the process for callMenu must have a lot more going on. I'll update here if I find a good way to do it.
Feels like a bit of a hack, but so far all looks good.

Replaced 'X' in Input keymapper from 'escape' to 'mapMenu', then stuck this in the Scene_Map update

if (Input.isTriggered("mapMenu")) {
if (this._ringCommandWindow.visible) {
SoundManager.playCancel();
this.closeCommand();
} else if (this._itemWindow.visible) {
SoundManager.playCancel();
this._helpWindow.hide();
this.closeItem();
this.openRingCommand();
} else if (this._quickSpellWindow.visible) {
SoundManager.playCancel();
this._helpWindow.hide();
this.closeQuickSpell();
this.openRingCommand();
} else if (!this._ringCommandWindow.visible) {
SoundManager.playOk();
this.openRingCommand();
}
}

Which basically changes the function of the X key to either open the command menu, or close the active menu, which is similar to its default function.

Escape still does it's own thing. I'll prob remap that to do something else like push Scene_Options since I don't mind that pausing the game.

Original thread: https://forums.rpgmakerweb.com/threads/replace-function-of-menu-keys-x-and-esc.121193/