Key Input

● ARCHIVED · READ-ONLY
Started by Chrisx994 4 posts View original ↗
  1. Hi everyone! I was working on a riddle for my game when i found a problem. I'll explain: i wanted to make an event that makes piano keys appear as image and i wanted to bind every key to a keyboard key. Problem is that the "Input.isTriggered("key") works only with game commands (could be that i'm doing it wrong?) and also i'd need 13 keys (so if someone plays with a pad it would be a problem)
    To explain better the minigame is like in FF VIII when in Ultimecia Castle you have to make Tiamat spawn.
    Thanks for your help!
  2. You can use a couple of yanfly plugins. Perhaps picture common events and keyboard input. I'm not sure how that works though, since I make my own plugins.
  3. I poked around in the rpg_core.js to see how they handle their key bindings, and came up with this table:
    Spoiler
    Code:
    /**
     * 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
    };

    The numbers on the left are the "keycodes", numbers that represent the key's position on the keyboard. The text on the right is the name assigned to them- keys with the same name are treated as the same key by the game engine.

    In short, your choices are to use a plugin that modifies or adds keys for you (I think Yanfly has one), or to extend the definition of Input.keyMapper to include your own keys (you can find key codes from something like this site), and then check for those new inputs with your script.
  4. Thanks a lot for your help! I was able to make it somehow