API reference Download Markdown

Input

For a default first-person player, attach the controllers-3d package component. It owns movement input, pointer capture and touch feedback; keep game hooks for your own actions. Its generated adapter connects those controls to the engine's camera, body and component lifecycle APIs.

Keyboard

Keyboard hooks deliver presses and releases. Keep held state for OnUpdate and clear it through OnInputReset.

func keyboard(held map[engine.Key]bool) engine.Hooks {
    return engine.Hooks{
        OnKeyDown: func(key engine.Key) { held[key] = true },
        OnKeyUp: func(key engine.Key) { delete(held, key) },
        OnInputReset: func() { clear(held) },
    }
}

Pointer input

Scroll to see all columns.

PointerInput fieldMeaning
ID, KindPointer identity and mouse/touch source
PhaseDown, move, up or cancel
X, YLogical canvas coordinates
DeltaX, DeltaYRelative movement for dragging or mouse look
CapturedWhether capture is active

SetCursorCaptured(true) requests mouse capture. Check Captured before using capture-dependent controls, and release capture when leaving them.

Track each touch by ID. PointerCancel ends one gesture; OnInputReset clears all held state. Modal UI can consume gameplay input before your hooks receive it. Use Camera 2D to convert logical pointer positions into world positions.

UI input routing ยท Crate room touch controls

The full event bounds and routing rules are in .karty/docs/pointer-input.md.