Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-input-action

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Wire keyboard, mouse, touch and action state; navigate SceneStack pages. Use for focus, held-key resets, session gates, DOM canvas errors or persistent push/pop.

  • 10 files
  • 38.8 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-input-action

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescontracts.md

≈1.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Derived from the cocosair-input-action skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Contracts

  • Event enums, not class constants: Input.EventType is the InputEventType enum (src/cocos/input/input.ts:160; values at src/cocos/input/types/event-enum.ts:277, e.g. TOUCH_START :285, MOUSE_DOWN :321, KEY_DOWN :367) and SystemEvent.EventType is SystemEventType (src/cocos/input/system-event.ts:72). PAL converts mouse to touch, so Input.EventType.TOUCH_START also fires for a primary mouse press (src/cocos/input/input.ts:96). EventMouse has no MOUSE_DOWN static; use the enum.
  • Action identity is per (action, source): a source is { backend, physicalCode? , keyCode?, pointerId? } with at least one identity field, and airActionSourceKey namespaces backends so a native keyCode and a dom physicalCode never merge (src/air/action-state.ts:51-59, :195-200, :203-229). Multiple sources on one action are OR-ed: releasing one leaves the others held (src/air/action-state.ts:151-152).
  • press is idempotent per (action, source): re-pressing an already-active source (key repeat) returns false and does not re-arm the press edge (src/air/action-state.ts:369-385, doc :143-150). consumeTick drains the ordered, non-deduped edge queue and returns empty (no replay) when nothing arrived (src/air/action-state.ts:420-444).
  • reset(reason) has exactly seven reasons - blur | hidden | pause | restart | deactivate | dispose | manual (src/air/action-state.ts:92); it clears active sources and the pending queue with no synthetic edges and never removes listeners; detaching is the adapter's job (src/air/action-state.ts:165-171, impl :446-453; src/air/action-input.ts:24-26). lastReset() reports the reason plus a monotonic count (src/air/action-state.ts:94-100).
  • The adapter backend option is only native | dom (src/air/action-input.ts:107); manual exists as a source backend for explicit press/release on the reducer (src/air/action-state.ts:41) but is not an adapter backend. dom REQUIRES an explicit canvas and throws AIR_E_INVALID_SOURCE otherwise; it never auto-discovers #GameCanvas (src/air/action-input.ts:156-158, doc :110-113). native uses canvas only as the requestFocus target.
  • Focus and editable targets: attach never calls focus(), so Start/Resume needs an explicit adapter.requestFocus() (src/air/action-input.ts:22, :131, :395-399); keydown is admitted unless the event target is INPUT/TEXTAREA/SELECT or contenteditable, while an already-held keyup still releases (src/air/action-input.ts:139-146, :208-215, :239-248). dom listens on window in capture phase so it runs before any canvas block (src/air/action-input.ts:294-295).
  • createSessionGate() takes no arguments and returns { generation, active, deactivateReason, activate(), deactivate(reason?), onChange?, offChange? }; activate increments the generation, deactivate rejects further presses (src/air/action-input.ts:51-100, :178). The adapter subscribes to onChange and resets on transition - deactivate -> reset('deactivate'), new generation -> reset('restart') (src/air/action-input.ts:325-330).
  • SceneStack defaults maxCachedPages to 4 and reads the block canvas from document.getElementById('GameCanvas') when none is passed (src/air/scene-stack.ts:61-63). During transitionMs both the new and the previous page stay active (dual-page window) and a capture-phase listener calls stopImmediatePropagation() on the canvas before PAL handlers, counting each block (src/air/scene-stack.ts:83-101, :160-169). LRU eviction removes the handle from the navigation stack before destroying the node, so an evicted page is never returned to by pop() (src/air/scene-stack.ts:145-152).
  • Audio autoplay unlock is an engine/browser policy concern: AudioService surfaces an un-unlocked play as a non-advancing currentTime rather than throwing (src/air/audio-service.ts:11-12), and a systemEvent/input gesture is the usual unlock trigger; the audio-video skill owns that flow. All symbols above - input, systemEvent, EventTouch, EventKeyboard, EventMouse, KeyCode, Input, SystemEvent, SystemEventType, createActionState, createActionInput, createSessionGate, SceneStack, AudioService - are on the bundle export block (build/cocosair.module.js, currently :161574).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "map keys, touch or mouse to named actions",
  "keys stop firing while an input has focus",
  "DOM input fails without an explicit canvas",
  "clear held actions after blur or page hiding",
  "preserve page state across push/pop transitions"
]
owns
[
  "native-input",
  "action-state",
  "dom-input",
  "focus-reset",
  "session-gate",
  "scene-stack"
]
not_for
[
  "full scene replacement -> cocosair-application",
  "DOM overlay geometry -> cocosair-graphics-and-dom",
  "node lifecycle and custom events -> cocosair-scene-graph"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "处理原生和 DOM 输入、动作状态、焦点、会话门禁及 SceneStack。用于按键触摸、动作映射、输入阻断或清理问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-input-action