How to listen for cancel on a window?

So I have created a window that opens, it uses window base as the parent class. How ever, when the window opens, hitting escape does nothing and I cant seem to find any where in the core source where hitting escape is listened too.

The window is opened by you going into the menu, selecting a new menu entry and hitting enter, then a new window is opened.

How do you listen for escape and then close the window on escape
You'll need to add more onto the Scene_Menu class, since that's where the window lives. You'll need to add to the update function, including a check for Input.isTriggered("cancel"), and then from there handling the input. However, since you're in the menu scene, you'll also need to worry about the default behavior. Instead of overwriting the update method, it is highly recommended you instead alias it to maintain compatibility with  other plugins that also change that function. By default, Scene_Menu binds the cancel command to Scene_Base's popScene function. However, because of the way inheritance works, we can add alias and change this method for this class only still.

However, here you have two options. You can either add a check in an aliased popScene function to make sure the window isn't open, and if it is close that first and don't close the scene, OR you could rebind the default cancel handler in Scene_Menu to your own function that will do this check, and call popScene if the window is not open. Though after thinking about it a little bit, either option should be about the same in terms of compatibility, I'd still recommend going the route of aliasing popScene and just adding your check there.

I know the official documentation is very sparse and for the specifics of most classes, actually kind of useless, but I intend to get some better documentation available to the public as soon as possible, as it's best we educate new scripters on the proper way to do things before they pick up bad habits and end up causing a compatibility nightmare with RMMV. Unfortunately, due to time constraints, a busy schedule, and just plain old being burned out, this will probably take a long time to get done. :<
Little hint, with es6:

class Something exends Scene_Base{ initialize() { super.initialize(this) } };

"Aliasing" is done for you. Just a small tip.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

at OP's request

(you know, you could have said thank you to the person who answered your request, in addition to correcting them 😉 )

Original thread: https://forums.rpgmakerweb.com/threads/how-to-listen-for-cancel-on-a-window.47123/