MV Access to gamepad command

Hello,
My objective is to assign to right-clic (mouse), escape (keyboard) AND Y button (gamepad) a common event.
I would like to allow players to choose their prefered way to run my game (keyboard, mouse or gamepad) and allow them to easily access a special menu (via a custom Common event).
I have set on disabled the normal menu access.

It's ok for mouse and keyboard with the following plugin (it's my first plugin...) :
(function() { var _clicdroit = Scene_Map.prototype.update Scene_Map.prototype.update = function() { _clicdroit.call(this); if ((TouchInput.isCancelled()) || (Input.isTriggered('escape'))) { $gameTemp.reserveCommonEvent(1); } } })();

But I don't see how to assign a gamepad button... I've tried something like this :
(Input.isTriggered('$Y'))
and it don't work.
I've searched here on the forum but i only find big plugins with no explanation of the way i could call a gamepad button.
Thank you for your help !
Arnaud
The engine maps keyboard keycode and gamepad button index to a button name. This allows different inputs to map to the same button name.

'escape' is a special button name: it matches the 'menu' or 'cancel' names.
So Input.isTriggered('escape') means "has a 'menu' or 'cancel' button been triggered?".

[Edit: oops. Actually, pressing 'escape' counts as pressing either 'menu' or 'cancel'. And gamepads map those buttons directly, rather than through 'escape'. Cf Input._isEscapeCompatible, rpg_core.js.]

The default gamepad button index for 'menu' is 3 (commented as the "Y" button in the core scripts).

The core engine has separate maps for keyboard and gamepad buttons:
Spoiler: rpg_core.js excerpt
JavaScript:
/**
 * A hash table to convert from a virtual key code to a mapped key name.
 *
 * @static
 * @property keyMapper
 * @type Object
 */
Input.keyMapper = {
    9: 'tab',       // tab
    13: 'ok',       // enter
    16: 'shift',    // shift
    17: 'control',  // control
    18: 'control',  // alt
    27: 'escape',   // escape
    32: 'ok',       // space
    33: 'pageup',   // pageup
    34: 'pagedown', // pagedown
    37: 'left',     // left arrow
    38: 'up',       // up arrow
    39: 'right',    // right arrow
    40: 'down',     // down arrow
    45: 'escape',   // insert
    81: 'pageup',   // Q
    87: 'pagedown', // W
    88: 'escape',   // X
    90: 'ok',       // Z
    96: 'escape',   // numpad 0
    98: 'down',     // numpad 2
    100: 'left',    // numpad 4
    102: 'right',   // numpad 6
    104: 'up',      // numpad 8
    120: 'debug'    // F9
};

/**
 * A hash table to convert from a gamepad button to a mapped key name.
 *
 * @static
 * @property gamepadMapper
 * @type Object
 */
Input.gamepadMapper = {
    0: 'ok',        // A
    1: 'cancel',    // B
    2: 'shift',     // X
    3: 'menu',      // Y
    4: 'pageup',    // LB
    5: 'pagedown',  // RB
    12: 'up',       // D-pad up
    13: 'down',     // D-pad down
    14: 'left',     // D-pad left
    15: 'right',    // D-pad right
};
Thank you ! I used 'escape' but i understand now this term had no link with the gamepad.
I just had to change 'escape' by 'cancel'.
Now it works fine. Thank you again for your quick and accurate answer 🙂
This thread is being closed due to being solved. If you need it reopened, report it to let us know why. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/access-to-gamepad-command.162380/