Cocos AIR native input and the action layer
Stop once you can answer the task. Do not read another same-topic reference for the same question.
Scope: Native/DOM input, held/pressed/released actions, session gates and persistent pages.
Environment: use package imports in apps; source paths require an AIR checkout. See context.
Quick Start
For complete setup and teardown, read Quick Start.
Siblings: direct dependencies; reuse loaded skills.
Triggers
- Handle touch, keyboard or mouse events
- Map keys and pointers into named actions
- Gate paused or backgrounded input
- Keys stop firing while editing text
- Reset actions or detach event listeners
- Push or pop persistent pages with transitions
Exact API and symptom mappings: triggers.
Contracts
Keep native and DOM action-source contracts distinct; DOM input needs an explicit canvas. Pair each listener with its own callback-specific off. Respect session generations, focus and SceneStack input blocking.
Read references/contracts.md only when the task needs exact option rules, limits, error behavior or source annotations. Prefer the topic references below for a narrower question.
Common Mistakes
- [HIGH] DOM input needs an explicit canvas.
- [HIGH] reset() does not remove event listeners.
- [MEDIUM] Editable focus intentionally suppresses key handling.
Read relevant wrong/right examples before implementation.
Reference map
- Read raw events? - Enums and event payloads
- Track held actions? - Sources, edges and resets
- Wire an input backend? - Canvas, focus and cleanup
- Preserve page state? - Transitions and eviction