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.

referencescommon-mistakes.md

≈516 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.

Common Mistakes

[HIGH] Using the dom backend and expecting the canvas to be found for you

Wrong:

const adapter = createActionInput({ state, backend: 'dom' }); // AIR_E_INVALID_SOURCE
adapter.attach();

Correct:

const canvas = document.getElementById('GameCanvas');
const adapter = createActionInput({ state, backend: 'dom', canvas });
adapter.attach();

dom binds pointer events to that canvas, so the factory throws AIR_E_INVALID_SOURCE when it is missing (src/air/action-input.ts:156-158); unlike SceneStack it does not fall back to document.getElementById('GameCanvas'), and it never auto-discovers (src/air/action-input.ts:110-113).

[HIGH] Assuming reset() unhooked the event listeners

Wrong:

state.reset('pause'); // believes no listener is left attached

Correct:

state.reset('pause'); // clears held state only
adapter.detach();     // or adapter.dispose() to also unbind the gate

reset(reason) clears active sources and the pending queue but keeps bindings and touches no listener (src/air/action-state.ts:165-171, impl :446-453); detaching is the adapter's separate concern (src/air/action-input.ts:24-26, :129-130).

[MEDIUM] Expecting keys to keep firing while an input element has focus

Wrong:

// user is typing in a text field, code still assumes 'fire' presses

Correct:

// editable keydown is filtered out; a re-focus back onto the canvas is explicit
adapter.requestFocus(); // Start/Resume path only; attach never steals focus

An admitted keydown is skipped when the target is INPUT/TEXTAREA/SELECT or contenteditable (src/air/action-input.ts:139-146, :208-215), and attach does not grab focus, so without a requestFocus() a canvas-bound native feed can miss presses (src/air/action-input.ts:22, :395-399).

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