MZ Blocking default inputs in custom Input.KeyMapper plug-in

I'm making my own simple KeyMapper plug-in, and as well as adding new customs keys, I need to block the input of some default keys when a switch is active and replace them with my own. I'm comfortable adding new keys, but I'm unsure of how to approach blocking and changing the input of existing ones.
For example, the 'x' key shares the escape function with the 'esc' key. I want to use the 'x' key for my own input while a common event is running, but I want the 'x' key to keep its default function while that event is not running. (The way I know how to check if a common event is running is checking if the switch it runs parallel to is active). I'd appreciate some help in understanding how to do this. Thank you.
You could modify it directly at the beginning of the common event with a script call:
JavaScript:
Input._keyMapper[88] = 'x';
You will be able to check it with Input.isTriggered('x') or isPressed('x'), etc.

At the end of the common event, revert it back:
JavaScript:
Input._keyMapper[88] = 'escape';
You could modify it directly at the beginning of the common event with a script call:
JavaScript:
Input._keyMapper[88] = 'x';
You will be able to check it with Input.isTriggered('x') or isPressed('x'), etc.

At the end of the common event, revert it back:
JavaScript:
Input._keyMapper[88] = 'escape';
Thank you, that sounds like a good method.

Original thread: https://forums.rpgmakerweb.com/threads/blocking-default-inputs-in-custom-input-keymapper-plug-in.174945/