godot-input
Installation
SKILL.md
Input (4.7)
See the project's actions with python ../godot-core/scripts/project_inspect.py → input. Reuse those action names.
Actions, not keys
- Define actions in Project Settings → Input Map (stored in
project.godot [input]). Bind every action to keyboard and gamepad from day one. Use physical keycodes (physical_keycode) so WASD works on AZERTY. - Polling in
_physics_process/_process:Input.is_action_pressed,is_action_just_pressedandis_action_just_released. Analog values:Input.get_vector(&"move_left", &"move_right", &"move_up", &"move_down")returns a circular deadzone and a normalized length.get_axis(neg, pos)andget_action_strengthcover the rest. - Events:
_unhandled_input(event)handles gameplay (UI gets first chance in_gui_input)._inputsees everything first, so use it only for global hotkeys and mark them handled withget_viewport().set_input_as_handled()._shortcut_inputis for menus' shortcuts. event.is_action_pressed(&"jump")inside event callbacks. Addallow_echofor key repeat, andexact_matchto require exactly those modifiers.- 4.7: keyboard and mouse events report
event.device == InputEvent.DEVICE_ID_KEYBOARD/DEVICE_ID_MOUSE, no longer 0. Gamepads keep 0..N. Don't comparedevice == 0to mean "keyboard". - In C#, cache action names:
static readonly StringName Jump = "jump";.