Your players may want to use a keyboard or a gamepad to play your games. Often, you will need to support multiple input devices.
For example, you may want the D key, the → key, and the joystick to all make the character move to the right.
Godot’s Input Map solves this problem for you: it maps a
name to multiple keys and buttons.To manage your Input Map, you go to the Project -> Project Settings… window and then click on the Input Map tab.
The Input Map window has a bar at the top to add new input names and a list of existing names and corresponding inputs.
There, you can see the name of each existing action over a light grey background. Below each name, you’ll find the list of corresponding inputs.
When the player presses any of these inputs, Godot will fire the corresponding action, allowing you to react to it in your code.
All the actions that start with ui_ are predefined and used by the Godot editor.
You can use them when coding your game’s user interface or plugins. However, we recommend creating new input actions for the rest of your gameplay to avoid conflicts when interacting with your game’s UI.
To define a new action, click in the bar next to Action. You type the name of your action, for example, move_right, and press Enter or click the Add button.
Your new action then appears at the bottom of the window.
To map keys or buttons to this action, click the plus icon to its right.
You’re presented with four options:
Players use different keyboard layouts around the world.
For example, there are QWERTY keyboards in English-speaking countries, but the most common layout in France is AZERTY.
When trying to map to specific letters on the keyboard, like WASD to move in a first-person game, French players will end up with an inconvenient layout. For them, the keys aren’t laid out like the arrow keys, and this will require them to change input settings before playing.
That’s why Godot introduced the Physical Key option. Instead of mapping to a given letter, it records the position of the key on the keyboard. For example, if you record your Physical Key as W on the QWERTY keyboard, Godot will save this as “the second letter on the first letter row.”
This makes the position of keys like WASD consistent across keyboard layouts.
We recommend using it if you want to use letter keys for movement.