Input Handling logo

Input Handling

Community
jame581
input-handling

Use when implementing input — InputEvent system, Input Map actions, controllers/gamepads, mouse/touch, action rebinding, and input architecture

Overview

Publisherjame581
RepositoryGodotPrompter
Skill nameinput-handling
Stars
808
Forks
47
Bundled files
6
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 6 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by jame581 on GitHub. Read the source before you install it.

Installation

Install the Input Handling AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jame581/GodotPrompter/tree/master/skills/input-handling
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jame581/GodotPrompter.git /tmp/GodotPrompter
mkdir -p .claude/skills
cp -r /tmp/GodotPrompter/skills/input-handling .claude/skills/input-handling
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Input Handling in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Input Handling on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Input Handling is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Input Handling in Godot 4.3+

All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.

Related skills: player-controller for movement driven by input, godot-ui for UI input focus and navigation, save-load for persisting custom key bindings, responsive-ui for touch vs desktop input adaptation, xr-development for XR controller and hand tracking input, mobile-development for mobile sensors and app lifecycle.


1. Core Concepts

Input Flow

Hardware Event (key, mouse, gamepad)
    ↓
Engine converts to InputEvent
    ↓
_input()              ← raw input, runs first
    ↓
_shortcut_input()     ← for global shortcuts
    ↓
UI Control nodes      ← buttons, sliders consume events
    ↓
_unhandled_key_input() ← unhandled key-only events
    ↓
_unhandled_input()    ← game input (movement, actions)

Where to Handle Input

MethodUse ForWhen It Runs
_input()Camera look, global hotkeysFirst — before everything
_shortcut_input()Global shortcuts (pause, screenshot)After _input, before UI
_unhandled_key_input()Key-only events that UI didn't consumeAfter UI, keys only
_unhandled_input()Gameplay actions (jump, attack, interact)Last — after UI consumes
Input.is_action_pressed() in _physics_process()Continuous movementN/A — polling, not event-driven

Rule of thumb: Use _unhandled_input() for discrete game actions (jump, attack). Use Input polling in _physics_process() for continuous movement. Use _input() only when you need input before UI consumes it (e.g., mouse look).

InputEvent Hierarchy

InputEvent
├── InputEventKey              ← keyboard
├── InputEventMouseButton      ← mouse clicks
├── InputEventMouseMotion      ← mouse movement
├── InputEventJoypadButton     ← gamepad buttons
├── InputEventJoypadMotion     ← gamepad sticks/triggers
├── InputEventScreenTouch      ← touchscreen tap
├── InputEventScreenDrag       ← touchscreen drag
├── InputEventAction           ← synthetic action events
├── InputEventMIDI             ← MIDI devices
└── InputEventGesture          ← pinch, pan gestures
    ├── InputEventMagnifyGesture
    └── InputEventPanGesture

2. Input Map Setup

Define actions in Project > Project Settings > Input Map instead of checking raw keycodes. This decouples game logic from specific keys and enables rebinding.

Default Project Actions

Godot ships with ui_* actions: ui_accept, ui_cancel, ui_left, ui_right, ui_up, ui_down, etc. These are used by UI controls for keyboard navigation. You can use them for gameplay but creating custom actions is preferred to avoid conflicts.

Adding Actions in Code

Actions can be created at runtime with InputMap.add_action() + InputMap.action_add_event() — typically in an autoload _ready(), guarded by InputMap.has_action(). Define actions in the editor Input Map; only add them in code for dynamically generated bindings or mod support.

See references/action-rebinding.md for the GDScript and C# snippet.

Recommended Action Names

Use descriptive, game-specific names instead of key names:

GoodBadWhy
move_leftpress_aDecoupled from physical key
attackleft_clickWorks for mouse and gamepad
interactpress_eRebindable without changing logic
sprinthold_shiftInput-agnostic
pausepress_escapeCan map to gamepad Start button too

3. Reading Input — Events vs Polling

Event-Driven (Discrete Actions)

Use _unhandled_input() for one-shot actions: jump, attack, interact, pause.

GDScript
gdscript
func _unhandled_input(event: InputEvent) -> void:
    if event.is_action_pressed("jump"):
        _jump()
        get_viewport().set_input_as_handled()  # prevent further propagation

    if event.is_action_pressed("interact"):
        _interact()

    if event.is_action_pressed("pause"):
        get_tree().paused = not get_tree().paused
        get_viewport().set_input_as_handled()
C#
csharp
public override void _UnhandledInput(InputEvent @event)
{
    if (@event.IsActionPressed("jump"))
    {
        Jump();
        GetViewport().SetInputAsHandled();
    }

    if (@event.IsActionPressed("interact"))
        Interact();

    if (@event.IsActionPressed("pause"))
    {
        GetTree().Paused = !GetTree().Paused;
        GetViewport().SetInputAsHandled();
    }
}

Polling (Continuous Input)

Use Input singleton in _physics_process() for held buttons and analog axes.

GDScript
gdscript
func _physics_process(delta: float) -> void:
    # Movement vector from 4 directional actions
    var direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
    velocity = direction * speed

    # Check if a button is held
    if Input.is_action_pressed("sprint"):
        velocity *= 1.5

    move_and_slide()
C#
csharp
public override void _PhysicsProcess(double delta)
{
    Vector2 direction = Input.GetVector("move_left", "move_right", "move_up", "move_down");
    Velocity = direction * Speed;

    if (Input.IsActionPressed("sprint"))
        Velocity *= 1.5f;

    MoveAndSlide();
}

Key Input Methods

MethodReturnsUse For
Input.is_action_pressed()boolHeld buttons (sprint, crouch, fire)
Input.is_action_just_pressed()boolOne-shot triggers (jump, interact)
Input.is_action_just_released()boolRelease triggers (variable jump cut)
Input.get_action_strength()floatAnalog pressure (0.0–1.0)
Input.get_axis()floatSingle axis (-1.0 to 1.0)
Input.get_vector()Vector22D direction, normalized
event.is_action_pressed()boolCheck in _unhandled_input callback
event.is_action_released()boolCheck in _unhandled_input callback

Input.is_action_just_pressed() in _physics_process() can miss inputs if the physics framerate is lower than the render framerate. For reliability, catch one-shot actions in _unhandled_input() and set a flag, or use the input buffering pattern below.

Input Buffering

Buffer discrete actions so they aren't lost between physics frames: catch the action in _unhandled_input(), set a flag with a short timer (0.1 s is typical), and consume the flag in _physics_process().

See references/input-buffering.md for the full GDScript and C# jump-buffer implementation.


4. Mouse Input

InputEventMouseMotion.relative for camera look (with Input.MOUSE_MODE_CAPTURED), InputEventMouseButton for clicks. Mouse modes: VISIBLE, HIDDEN, CAPTURED, CONFINED. Custom cursor via Input.set_custom_mouse_cursor(texture, shape, hotspot).

See references/mouse.md for the full GDScript and C# recipes (camera-look with sensitivity + invert toggle, mouse-mode switching, button events, custom cursor with shape variants).


5. Controller / Gamepad Support

Input.get_connected_joypads() for runtime detection, Input.joy_connection_changed signal for hot-plug. Use Input Map actions with joypad button events for portability. Analog sticks: Input.get_vector("left", "right", "up", "down", deadzone) returns a length-clamped Vector2 with built-in deadzone.

See references/gamepad.md for the GDScript and C# recipes (controller detection, deadzone analog reading, vibration via start_joy_vibration, motion sensors, detecting last-input-device for UI prompt swapping).

Godot 4.7+: Joypad motion sensors — Input.get_joy_accelerometer(device) / get_joy_gyroscope(device) (both Vector3), guarded by has_joy_motion_sensors() and enabled with set_joy_motion_sensors_enabled(); recipe in references/gamepad.md. Vibration is now queryable — Input.has_joy_vibration(device) plus get_joy_vibration_strength/duration/remaining_duration(). JoyButton gains JOY_BUTTON_MISC2 (21) through JOY_BUTTON_MISC6 (25) (C#: JoyButton.Misc2…). New project setting input_devices/joypads/ignore_joypad_on_unfocused_application (default false) ignores joypad input (including motion sensors) and LED changes and stops vibration while the app is unfocused.


6. Touch Input

InputEventScreenTouch for tap/release, InputEventScreenDrag for finger drag. Multi-touch tracked by event.index. Enable Project Settings → Input Devices → Pointing → Emulate Touch From Mouse to test on desktop.

See references/touch.md for the GDScript and C# basic touch event handling and the emulate-touch-from-mouse setting.

VirtualJoystick (Godot 4.7+)

Godot 4.7 adds a built-in VirtualJoystick Control node for on-screen touch joysticks. Add it to a CanvasLayer, point its action_up/down/left/right properties (StringName, defaults &"ui_up" etc.) at your movement actions, and it triggers those actions like a physical stick.

gdscript
@onready var joystick: VirtualJoystick = $CanvasLayer/VirtualJoystick

func _ready() -> void:
    joystick.action_left = &"move_left"
    joystick.action_right = &"move_right"
    joystick.action_up = &"move_up"
    joystick.action_down = &"move_down"
    joystick.joystick_mode = VirtualJoystick.JOYSTICK_DYNAMIC  # recenters on touch
    joystick.visibility_mode = VirtualJoystick.VISIBILITY_WHEN_TOUCHED

func _physics_process(_delta: float) -> void:
    # The joystick drives the actions — normal polling just works
    var direction := Input.get_vector("move_left", "move_right", "move_up", "move_down")
csharp
private VirtualJoystick _joystick;

public override void _Ready()
{
    _joystick = GetNode<VirtualJoystick>("CanvasLayer/VirtualJoystick");
    _joystick.ActionLeft = "move_left";
    _joystick.ActionRight = "move_right";
    _joystick.ActionUp = "move_up";
    _joystick.ActionDown = "move_down";
    _joystick.JoystickMode = VirtualJoystick.JoystickModeEnum.Dynamic;
    _joystick.VisibilityMode = VirtualJoystick.VisibilityModeEnum.WhenTouched;
}

public override void _PhysicsProcess(double delta)
{
    Vector2 direction = Input.GetVector("move_left", "move_right", "move_up", "move_down");
}

Tune deadzone_ratio (default 0.0 — InputMap action deadzones apply on top), clampzone_ratio (1.0), joystick_size (100.0 px), and tip_size (50.0 px); restyle via the normal_joystick/normal_tip and pressed_joystick/pressed_tip StyleBox theme slots. The released(input_vector) and flicked(input_vector) signals report final direction and strength.


7. Action Rebinding at Runtime

Three steps: (1) capture the user's chosen key via _input while in "rebinding" mode, (2) call InputMap.action_erase_events(action) then InputMap.action_add_event(action, new_event), (3) persist via ConfigFile and reload on launch.

See references/action-rebinding.md for the full GDScript and C# rebinding flow including ConfigFile save/load and the typical "press a key" capture UI.


8. Consuming and Propagating Input

Input propagates in reverse scene tree order (deepest child first, root last); call get_viewport().set_input_as_handled() after consuming an event to stop it reaching other nodes. During pause, only nodes with process_mode = PROCESS_MODE_ALWAYS receive input.

See references/event-propagation.md for the GDScript and C# recipes (stopping propagation, node processing order, receiving input while paused).


9. Common Pitfalls

SymptomCauseFix
Action not recognizedAction name not defined in Input MapAdd the action in Project > Project Settings > Input Map
is_action_just_pressed() misses inputCalled in _physics_process at low tick rateCatch discrete actions in _unhandled_input() instead
Input still fires when UI is openUsing _input() instead of _unhandled_input()Switch to _unhandled_input() so UI consumes events first
Mouse look works through menusMouse motion in _input() without mode checkGuard with if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED
Gamepad stick driftsDeadzone too low or not setSet deadzone per-action in Input Map (0.2 is a good default)
Controller not detectedNot connected before game startConnect joy_connection_changed signal, handle hot-plug
Key rebinding captures modifier keysNo filter for Shift/Ctrl/Alt aloneSkip events where keycode is a modifier key
Touch input doesn't work on desktop"Emulate Touch From Mouse" is disabledEnable in Project Settings > Input Devices > Pointing
Input fires during pauseNode process_mode is INHERIT (pauses with parent)Set pause menu to PROCESS_MODE_ALWAYS
Action triggers twice per pressSame action checked in both _input and _unhandled_inputPick one callback per action

⚠️ Changed in Godot 4.7: Mouse and keyboard device IDs changed from 0 to InputEvent.DEVICE_ID_MOUSE (32) and InputEvent.DEVICE_ID_KEYBOARD (16), because some joypads use 0 as their device ID. Code checking event.device == 0 to detect keyboard/mouse input silently breaks — compare against the constants or check the event type (event is InputEventKey) instead. See the 4.7 migration guide.


10. Implementation Checklist

  • All gameplay actions are defined in the Input Map — no raw keycodes in game logic
  • Discrete actions (jump, attack) use _unhandled_input(), not polling in _physics_process()
  • Continuous input (movement, sprint) uses Input.get_vector() / Input.is_action_pressed() in _physics_process()
  • Mouse look guards on Input.mouse_mode == MOUSE_MODE_CAPTURED to avoid rotating through menus
  • Each Input Map action has both keyboard and gamepad bindings for controller support
  • Gamepad deadzone is set per-action in Input Map (default 0.2)
  • Pause menu node has process_mode = PROCESS_MODE_ALWAYS to receive input while paused
  • get_viewport().set_input_as_handled() is called after consuming events that shouldn't propagate
  • Input device detection exists if showing keyboard vs gamepad UI prompts
  • Key rebinding saves to and loads from user:// on game launch

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Input Handling AI skill do?

Use when implementing input — InputEvent system, Input Map actions, controllers/gamepads, mouse/touch, action rebinding, and input architecture

Why use Input Handling on TypingMind?

Because you install it once and use it with any model. Input Handling is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Input Handling in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jame581/GodotPrompter/tree/master/skills/input-handling. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Input Handling?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Input Handling?

As many as you like. As long as a model supports skills, you can use Input Handling with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Input Handling AI skill free?

Yes. It is published on GitHub by jame581 under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇