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_pressed and is_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) and get_action_strength cover the rest.
  • Events: _unhandled_input(event) handles gameplay (UI gets first chance in _gui_input). _input sees everything first, so use it only for global hotkeys and mark them handled with get_viewport().set_input_as_handled(). _shortcut_input is for menus' shortcuts.
  • event.is_action_pressed(&"jump") inside event callbacks. Add allow_echo for key repeat, and exact_match to 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 compare device == 0 to mean "keyboard".
  • In C#, cache action names: static readonly StringName Jump = "jump";.
Installs
12
GitHub Stars
54
First Seen
9 days ago