MV Closing Menu with Javascript

Hey! So I was using this really helpful reddit post (the first reply) to bind the item menu to the "i" key, but they didn't say how you can use the same "i" key to close the item menu as well... it just don't feel as good to have to close it with ESC. I'm really bad at understanding code to do this myself and was hoping someone could help me out. VERY sorry if this is the wrong place to post this. :') Thank you!
I'm not used to plugins in RPG Maker MV yet, but the best shot is to use a custom plugin for it, instead of messing with the core code.

You can create a function that calls this method and import it as a plugin, it's a best practice. It seems that Yanfly have one for this.


Spoiler: Didn't tried it myself...
As some persons suggested on that post... Try to create a Commom Event labelled as Parallel, then, place a "Script" Event Command with the following code on it.

JavaScript:
// You put this code on a Commom Event - Parallel.
73: 'item_menu', // I

if (!SceneManager.isSceneChanging()) {
    this.updateCallItemMenu();
}

Scene_Map.prototype.updateCallItemMenu = function() {
    if (this.isItemMenuCalled()) {
        SceneManager.push(Scene_Item);
     }
};

Scene_Map.prototype.isItemMenuCalled = function() {
    return Input.isTriggered('item_menu');
};
Eliaquim has also a buttom common event, but you can also
make the above a bit shorter in a plugin rather running a parallel process.
as it can make the game lag if to many is used.

rather the button, and if pressed (if scene isn't open yet), to open,
or otherwise it closes, 1 function to do both rather than 3 in the example above.
I'm not used to plugins in RPG Maker MV yet, but the best shot is to use a custom plugin for it, instead of messing with the core code.

You can create a function that calls this method and import it as a plugin, it's a best practice. It seems that Yanfly have one for this.


Spoiler: Didn't tried it myself...
As some persons suggested on that post... Try to create a Commom Event labelled as Parallel, then, place a "Script" Event Command with the following code on it.

JavaScript:
// You put this code on a Commom Event - Parallel.
73: 'item_menu', // I

if (!SceneManager.isSceneChanging()) {
    this.updateCallItemMenu();
}

Scene_Map.prototype.updateCallItemMenu = function() {
    if (this.isItemMenuCalled()) {
        SceneManager.push(Scene_Item);
     }
};

Scene_Map.prototype.isItemMenuCalled = function() {
    return Input.isTriggered('item_menu');
};
Thank you, so I'm using the Yan plugin and I agree it's better to do this as a plugin, but I'm still having the issue of wrapping my head around using "i" to close the item menu. I'm not sure if the script event you sent me is suppose to help me with the yanfly plugin or with the original core code editing. If you could post a screenshot of how it's suppose to look in the event editor it might help as well cuz I understand better with visuals.
Eliaquim has also a buttom common event, but you can also
make the above a bit shorter in a plugin rather running a parallel process.
as it can make the game lag if to many is used.

rather the button, and if pressed (if scene isn't open yet), to open,
or otherwise it closes, 1 function to do both rather than 3 in the example above.

i don't know anything about coding to make plugins. 🙁
it takes time, I make while I learn 🙂
but use the plugin of eli and test it, it makes life easier.

Original thread: https://forums.rpgmakerweb.com/threads/closing-menu-with-javascript.151250/