Godot input handling

From nix-community/nur-combined · View interactive version

Godot input handling is an AI agent skill from the GitHub repository nix-community/nur-combined. Expert patterns for input handling covering InputMap actions, InputEvent processing, controller support, rebinding, deadzones, and input buffering. Use when setting up player controls, implementing input systems, or adding gamepad/accessibility features. Keywords InputMap, InputEvent, gamepad, contr

How to use this skill

Skill file

Input Handling

Handle keyboard, mouse, gamepad, and touch input with proper buffering and accessibility support.

Available Scripts

[advanced_input_buffer.gd](scripts/advanced_input_buffer.gd)

Frame-perfect input buffering system for responsive jumps, dashes, and combo chains.

[safe_runtime_rebind.gd](scripts/safe_runtime_rebind.gd)

Dynamic input rebinding with conflict detection, persistence, and multi-device support.

[analog_deadzone_manager.gd](scripts/analog_deadzone_manager.gd)

Radial deadzone management for analog sticks to eliminate drift while maintaining natural follow-through.

[multi_touch_gestures.gd](scripts/multi_touch_gestures.gd)

Handling touch, drags, and pinch-to-zoom gestures for mobile and touchscreen compatibility.

[input_echo_filter.gd](scripts/input_echo_filter.gd)

Filtering echo events to distinguish between hold-to-navigate (UI) and one-time gameplay actions.

[mouse_capture_manager.gd](scripts/mouse_capture_manager.gd)

Robust mouse capture and sensitivity scaling logic for FPS and mouse-intensive systems.

[hold_toggle_accessibility.gd](scripts/hold_toggle_accessibility.gd)

Software-side support for user-defined 'Hold' vs 'Toggle' accessibility preferences.

[glyph_prompt_manager.gd](scripts/glyph_prompt_manager.gd)

Real-time switching between Keyboard and Gamepad UI prompts based on the last active device.

[action_state_machine.gd](scripts/action_state_machine.gd)

Tracking the lifecycle of an action ('Just Pressed', 'Held', 'Released') for complex state logic.

[unhandled_input_priority.gd](scripts/unhandled_input_priority.gd)

Demonstrating the correct use of _unhandled_input to prevent gameplay logic from leaking into UI.

MANDATORY - For Responsive Controls: Read input_buffer.gd before implementing jump/dash mechanics.

NEVER Do in Input Handling


InputMap Actions

Setup: Project Settings → Input Map → Add action

# Check if action pressed this frame
if Input.is_action_just_pressed("jump"):
    jump()

# Check if action held
if Input.is_action_pressed("fire"):
    shoot()

# Check if action released
if Input.is_action_just_released("jump"):
    release_jump()

# Get axis (-1 to 1)
var direction := Input.get_axis("move_left", "move_right")

# Get vector
var input_vector := Input.get_vector("left", "right", "up", "down")

InputEvent Processing

func _input(event: InputEvent) -> void:
    if event is InputEventKey:
        if event.keycode == KEY_ESCAPE and event.pressed:
            pause_game()
    
    if event is InputEventMouseButton:
        if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
            click_position = event.position

Gamepad Support

# Detect controller connection
func _ready() -> void:
    Input.joy_connection_changed.connect(_on_joy_connection_changed)

func _on_joy_connection_changed(device: int, connected: bool) -> void:
    if connected:
        print("Controller ", device, " connected")

Reference

Related

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.