Full Input Keyboard

This script allows you to assign game keys to any key on your keyboard. It also provides methods for handling input such as checking for input triggers or releases.

This script was written by Cidiomar. The original post is copied below:

Hi, this is an rewrite of the RGSS3 Input with some features added.
224 keys in keytable
Input.release? added
Full Keyboard Layout Compatibility
UTF8 reading with accents

Download

Script: download here
Addon: Interpreter patch – Conditional branch works properly

Installation

Place this script below Materials and above Main

Usage

You will first see the Key Map, which gives you the names of the keys on your keyboard.

Following the Key Map, you will see the control settings

UP    = [KEYMAP[:UP]]
DOWN  = [KEYMAP[:DOWN]]
LEFT  = [KEYMAP[:LEFT]]
RIGHT = [KEYMAP[:RIGHT]]
A      = [KEYMAP[:SHIFT]]
B      = [KEYMAP[:ESCAPE]]
C      = [KEYMAP[:RETURN]]
X      = []
Y      = []
Z      = []
L      = [KEYMAP[:PRIOR]]
R      = [KEYMAP[:NEXT]]
F5     = [KEYMAP[:F5]]
F6     = [KEYMAP[:F6]]
F7     = [KEYMAP[:F7]]
F8     = [KEYMAP[:F8]]
F9     = [KEYMAP[:F9]]
SHIFT  = [KEYMAP[:SHIFT]]
CTRL   = [KEYMAP[:CONTROL]]
ALT    = [KEYMAP[:MENU]]

This is where you will set up your game’s keys. Just follow the format and look up the Key Map if you are not sure what the name of the key is.

You may also like...

154 Responses

  1. EXVA says:

    I know this post seems a bit late to the ball but this fixes the weird movement behavior. took like a few mins to figure it out.

    def self.dir4
    return 2 if self.press?(DOWN) unless self.press?(RIGHT) or self.press?(UP) or self.press?(LEFT)
    return 4 if self.press?(LEFT) unless self.press?(RIGHT) or self.press?(UP)
    return 6 if self.press?(RIGHT) unless self.press?(DOWN) or self.press?(UP) or self.press?(LEFT)
    return 8 if self.press?(UP) unless self.press?(DOWN) or self.press?(RIGHT) or self.press?(LEFT)
    return 0
    end

    • EXVA says:

      Edit, nope only half worked, only tested them one by one.

      return 2 if self.press?(DOWN) unless self.press?(RIGHT) or self.press?(UP) or self.press?(LEFT)

      works if the other returns aren’t listed, I maybe have to add else inbetween to see if that helps.

      • EXVA says:

        After a full night of trying every possible method to fix this with no luck, I traced the script all the way back to this demo & I’ve found the only work around using many scripts to its default scripts to use its build in override.

        https://forums.rpgmakerweb.com/index.php?threads/control-configuration-system-v1-5-04-07-2017.70517/

        Scripts are as followed

        Manual & Install Notes
        System Settings - Cidiomar
        Cidiomar's Input System
        Vocab Settings - Cidiomar
        Menu Settings
        Default Input Checks
        Main Functions

        ITs the last two that act as the override & I cut the Default Input Checks to this.

        module Input

        def self.pref_ax
        @pref_ax = ” if @pref_ax.nil?
        return @pref_ax
        end

        def self.pref_ax=(val)
        @pref_ax = val
        end

        def self.dir4
        @dir4 = 0 if @dir4.nil?
        return @dir4
        end

        def self.dir4=(val)
        @dir4 = val
        end

        def self.dir8
        @dir8 = 0 if @dir8.nil?
        return @dir8
        end

        def self.dir8=(val)
        @dir8 = val
        end

        def self.update_dir
        xx = self.get_x
        yy = self.get_y
        self.dir8 = self.num_dir(xx,yy)
        if xx != 0 && yy != 0
        if self.pref_ax == ‘x’
        yy = 0
        else
        xx = 0
        end
        elsif xx != 0
        self.pref_ax = ‘y’
        elsif yy != 0
        self.pref_ax = ‘x’
        end
        self.dir4 = self.num_dir(xx,yy)
        end

        def self.get_x
        xx = 0
        xx -= 1 if self.press_ex?($system[:p1][:f_left])
        xx += 1 if self.press_ex?($system[:p1][:f_right])
        return xx
        end

        def self.get_y
        yy = 0
        yy -= 1 if self.press_ex?($system[:p1][:f_up])
        yy += 1 if self.press_ex?($system[:p1][:f_down])
        return yy
        end

        def self.num_dir(x,y)
        if x != 0 || y != 0
        return 5 – y * 3 + x
        else
        return 0
        end
        end

        class << self; alias fix_dirs7761 update; end
        def self.update
        fix_dirs7761
        update_dir
        end

  2. owl says:

    I have had the worst possible time trying to remap the keys, can someone help?

  3. bob says:

    i mapped each key to what i wanted, then it gave me the error “line 419:type error occurred: cant convert array into integer” can someone help?

  4. anon says:

    Any way to use this script to let the player decide their keybindings? If not, do you (or anyone reading this) know of a script that does this?

  5. FMR says:

    The script works really well but it disables the Xbox360 controller. Which is widely use. Is there a way to make it work with this script?

  6. Andy says:

    When using this script, the 4 directional movement becomes a little bit clunky.

    Without the script installed, you are able to walk in one direction, and turn another direction as soon as you press another key; however, with this script, you can’t turn left or down while walking to the right until the right arrow key is released. Any way to make direction changes smoother?

    • Hime says:

      This is an interesting case, in the sense that there are some odd cases

      1. While holding the UP key, pressing left and right works
      2. While holding the DOWN key, pressing left and right do not work
      3. While holding the LEFT or RIGHT keys, pressing UP does not work

      It is determined that this is due to the way the logic for checking direction keys is done. It always checks down first, and then it checks left, right, and up. So if you’re pressing left, the code will always just say you’re pressing left. If you were to then press up while holding left, the code will see that you’re pressing left, and then it wouldn’t say you’re pressing up.

      Will need to figure out how to allow for such direction changes though.

      • Andy says:

        Is there a way to check for all keys pressed first, before returning the direction of the key most recently pressed?

        • Hime says:

          There is, but what would you do with that information?
          The script, as it stands, does not return the key “most recently pressed”.

          Instead, it returns “the first key it checks that’s currently pressed”

  7. MatthewRob says:

    How do i make the normal conditional branches work again? Like on if button X is pressed (Which is A for me) when i try to edit anything at all it says “line 369 type error occurred no implicit conversion from nil to interger????? Please help (A demo would be really nice cus idk how to make a “If button” pressed event)

  8. Fen says:

    This script clashes with Jet’s mouse system, initially.

    However, I found that simply putting the Mouse System script after this one, and binding “B” and “C” to :RBUTTON and :LBUTTON respectively sort of fixes the issues. It more or less functions the same, at any rate.

    .

    Thanks for the great script, Hime~

  9. narabuster says:

    Is there a RGSS2 version of this script? Since I’m using RPG Maker VX, a script like this would help me out a lot, but since it’s in RGSS3, I’m unable to use it.

    • Hime says:

      I am not sure if there is one for VX (or whether this works with VX). You can try asking on the forums.

      • narabuster says:

        This script doesn’t work with RMVX. In fact, it just crashes with the first line (line 37) after the comments. I was just wondering if you knew how to convert this in RGSS2. I’ll try asking in the forums though. Thanks!

  10. Torqus says:

    I’m using this script to enable players to move with WSAD as well As Up, Down, Left and Right arrows. Works 10/10.
    But what do I have to do if I want to set ESCAPE to trigger a Common event? I just want to show a HUD when the menu is opened. So i’ll have the key activating a Common event modifying a Switch. The only thing I can’t get to work is telling the ESCAPE key to activate a Common Event.
    Can you help me with this?

    • Hime says:

      The purpose of this script is to provide a way to utilize the entire keyboard, as well as provide some input bindings for scripts. You should look for a script that will allow you to bind keys to certain common events, using this script to specify which key to use.

  11. Futbol says:

    I’m not very knowledgeable with scripts. Would it be possible to set both the arrow keys and WASD keys to work for movement, battle, and menus using this script? I would like to be able to use either configuration on the fly. Thanks!

    • Hime says:

      Yes. In the configuration section, you can assign multiple keys to a single button. So for example if you want both the UP key and the W key to go up, you would say

      UP    = [KEYMAP[:UP], KEYMAP[:LETTER_W]]
      
      • Futbol says:

        Great! That helps tremendously. I tried it out just now and it seems to work without any problems. Thanks for the speedy and detailed response.

  12. Isfuturebright says:

    Are there anymappings for gamepads? Like KEYMAP[:GAMEPAD_UP] or something?

    Thanks for the script by the way.

    • Hime says:

      Unfortunately, the script only supports keyboard inputs and was mainly intended for keyboards. If you have a script that enables gamepad usage it may be possible to use that to map both keys and gamepad buttons.

  13. Zac says:

    I’m having a bit of trouble getting this to work, I switchd

    UP = [KEYMAP[:UP]] to UP = [KEYMAP[:LETTER_W]]

    but I still cant us “W” for the up button (wanting to use WASD because I cant test due to arrow keys not fucntioning.)

  14. Hibari says:

    Um, I would like to ask– and I don’t understand much about scripts, so.. Which one I must rewrite in order to change Up-Left-Down-Right to W-A-S-D? Thanks.

  15. How would i go about checking with a conditional branch if a custom key is being pressed? So far as I know you’d have to use a script call for anything beyond the default.

    • Hime says:

      Input.trigger?(:YOUR_KEY_HERE)

      I think you need to say things like

      Input.trigger?(:LETTER_X)

      Check the key map to determine what symbol to use.

  16. TheDrifter says:

    My Logitech Gamepad stopped working with my project once I started using the script. How do I map buttons for a Gamepad? Thank you!

  17. Lost Dragon says:

    I clicked on the “terms of use” link inside the script and it took me to some page that (I think) tried to give me malware.

    Does anyone know what the terms of use are? Also that link should probably be removed… Thanks.

    • Hime says:

      Thanks, the links used to point to the original posts (the domain has since expired and claimed by some other people). I will remove the links.
      I believe the terms of use was to credit the author shown in the post.

  18. Kazuki Takamura says:

    I was wondering how would I configure the following controls for my battle system:
    Z = Confirm
    X = Cancel
    V = Escape
    R = To open a scroll-able window so you can look up combo recipes (part of the battle system)
    D = Guard

    • Hime says:

      This script allows you to map keys on your keyboard to a virtual key map that the engine uses.

      You would have Z set to the LETTER_Z, X set to LETTER_X, and so on, but after that you need to tell your battle system what happens when the player presses those keys.

      That would be outside of the scope of this script.

  19. Shiori4me says:

    How would I get colon to work for the action button?
    (as in ‘ : ‘ for “Confirm/Action Button” is at your ring finger, ‘L’ for “Cancel/Menu” is at your middle finger, and “Dash” is ‘shift’ at your right pinky finger)
    I can get ‘L’ to work, but not the colon key, even though I tried both
    C = [KEYMAP[:RETURN], KEYMAP[:colon]
    and
    C = [KEYMAP[:RETURN], 0x3a]

    • Shiori4me says:

      I mean C = [KEYMAP[:RETURN], KEYMAP[:colon]]

    • Hime says:

      Try semi-colon. American keyboards require you to hold shift and press semi-colon to actually press colon.

      • Shiori4me says:

        Oh, durr. I live in America. I just wasn’t thinking right. But semicolon doesn’t work either.

        • Hime says:

          Oh, you’re right, semi-colon doesn’t work. I wonder if this applies to all of the other punctuation keys as well…

          • Shiori4me says:

            Well “question” (the term for the ‘?’ key) and “0slash” (that is, if that means the ‘/’ key for forward “slash”) doesn’t work either.
            I’m just trying to find something that is comfortable on the right hand and is far enough from the WASD placement of the left hand, but so far the keys I find would work the best are the ones that I either can’t use or don’t know if are available/know the term used for them.

          • Hime says:

            How about I,J,K,L? That seems to be a fairly common layout I’ve seen for 2-player games.

            I guess you’ll have to ask someone that’s left-handed to see how they optimize their keyboards for first-person shooters (if they do)

        • Hime says:

          For that matter, LESS, GREATER, and the other punctuation don’t work either…

          • Shiori4me says:

            That’s strange.
            Hm… Well so far the key combinations
            ‘U’ for cancel/map, ‘I’ for confirm/action, and ‘L’ for dash do work. But the position is just a tad awkward. Heheh.

  20. Shiori4me says:

    I’m a bit unsure with this one.
    So, in order to have WASD control, I’d have to change
    UP = [KEYMAP[:UP]]
    DOWN = [KEYMAP[:DOWN]]
    LEFT = [KEYMAP[:LEFT]]
    RIGHT = [KEYMAP[:RIGHT]]
    to
    LETTER_W = [KEYMAP[:UP]]
    LETTER_S = [KEYMAP[:DOWN]]
    LETTER_A = [KEYMAP[:LEFT]]
    LETTER_D = [KEYMAP[:RIGHT]]
    then change every mention of say “UP” to “LETTER_W”?

    • Hime says:

      You can also just change

      UP = [KEYMAP[:UP]]
      

      to

      UP = [KEYMAP[:LETTER_W]]
      

      And the game should automatically recognize the new key

      • Shiori4me says:

        Script ‘–Conditional Branch Fix’ line 24: SyntaxError occurred.

        unexpected ‘=’, expecting ‘(‘
        (when I try to put the rest of this btw, the site says I have an invalid security token, must be the way it’s worded where the site sees it as a code)

        • Hime says:

          Hmm I guess a little code can cause the comment system to go vicious lol.

          It sounds like you accidentally removed too many characters.

          • Shiori4me says:

            Wait… oops, I mean that was the script error I got when I added the addon script. I didn’t change anything with that. And the only thing I changed with the main script is that one part for WASD movement. So that’s why I’m confused, since I didn’t change around anything.

        • Hime says:

          I looked at the script and it looks like there were HTML-escaped characters for > and < which is a bit strange. I’ve fixed those.

          • Shiori4me says:

            Thanks. I’m not getting any errors so far. The reason I’m using WASD movement is because I’m also going to be using a mouse script. Hm, I wouldn’t know about people who are lefthanded. I don’t think you can condition a whole game based on what hand setting they choose (to have the action buttons on the left side of the keyboard, arrow keys for movement for lefthanders and to have the action buttons on the right and WASD movement for righthanders)

          • Hime says:

            It is possible, but additions would need to be added to the script to re-map the keys dynamically. Currently it assumes whatever your configuration settings are, that’s how it’ll be for the rest of the game.

  21. oliopro says:

    F9 is by default Debug no?

  22. oliopro says:

    Some questions about his script. Firstly you have menu and F5 > F9 on this list as reference for default buttons which I can’t see a direct link to which they are. Does menu relate to pressing X or F1 without this script installed? Also, which of those buttons do F2 and F12 correspond to, assuming F9 is as listed.

    My other question is if this script could be easily modified to reference controller inputs (specifically Xinput)? I’m obviously not talking about including pressure controls on those buttons, that’s not within this scripts power atm.

    • Hime says:

      F1 and F2, and F12 are reserved for the game’s own purposes.. F5 to F9 are freely available and don’t have anything assigned to them by default.

      I don’t know anything about controllers as I’ve never played with them.

  23. Moo says:

    I have… no idea how to get this to work. I don’t even know what this does. I want to make it so J is the action button, K is the menu/return button, and the like, but I don’t know how to do that or if this script or the addon can be used for such a function.

  1. September 2, 2013

    […] Full Input Script : Here (From Tsukihime’s blog who’s reposting […]

Leave a Reply

Your email address will not be published. Required fields are marked *