Script for key input not working

● ARCHIVED · READ-ONLY
Started by Milennin 4 posts View original ↗
  1. I come back to check on an older feature that used to work, but now, several engine updates later, this seems to have been broken.

    I had a Script on a conditional branch that checks if a key is pressed, and it would then act on that:
    Code:
    Input.isPressed('a')
    However, in the newer engine version, nothing happens. Any help on making this work again?
  2. This doesn't have to do with the version of MV, as this was never a feature of the base engine. More likely, you directly edited the rpg_core.js file and your edits were overwritten or you used a plugin to enable this feature and are no longer using it.

    In order for this to work, the game has to know what keyboard key corresponds to the letter 'a'. In a new plugin, put this line of code and you should be good to go:
    Code:
    Input.keyMapper[65] = 'a';
  3. Code:
    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
    };

    As @Aloe Guvner mentioned, you can add the "A" key into the keymapper using

    Code:
    Input.keyMapper[65] = 'a';

    You could add other keys using keycode and keyname pairs found on this chart. You could even rename them like the "ok", "escape" and so forth.
  4. Thanks, I got it working now. I guess I did that a long time ago and then forgot about it.