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.EventTypeis theInputEventTypeenum (src/cocos/input/input.ts:160; values atsrc/cocos/input/types/event-enum.ts:277, e.g.TOUCH_START:285,MOUSE_DOWN:321,KEY_DOWN:367) andSystemEvent.EventTypeisSystemEventType(src/cocos/input/system-event.ts:72). PAL converts mouse to touch, soInput.EventType.TOUCH_STARTalso fires for a primary mouse press (src/cocos/input/input.ts:96).EventMousehas noMOUSE_DOWNstatic; use the enum. - Action identity is per
(action, source): a source is{ backend, physicalCode? , keyCode?, pointerId? }with at least one identity field, andairActionSourceKeynamespaces backends so a nativekeyCodeand a domphysicalCodenever 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). pressis idempotent per(action, source): re-pressing an already-active source (key repeat) returnsfalseand does not re-arm the press edge (src/air/action-state.ts:369-385, doc:143-150).consumeTickdrains 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);manualexists as a source backend for explicitpress/releaseon the reducer (src/air/action-state.ts:41) but is not an adapter backend.domREQUIRES an explicitcanvasand throwsAIR_E_INVALID_SOURCEotherwise; it never auto-discovers#GameCanvas(src/air/action-input.ts:156-158, doc:110-113).nativeusescanvasonly as therequestFocustarget. - Focus and editable targets:
attachnever callsfocus(), so Start/Resume needs an explicitadapter.requestFocus()(src/air/action-input.ts:22,:131,:395-399); keydown is admitted unless the event target isINPUT/TEXTAREA/SELECTor contenteditable, while an already-held keyup still releases (src/air/action-input.ts:139-146,:208-215,:239-248).domlistens onwindowin 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? };activateincrements the generation,deactivaterejects further presses (src/air/action-input.ts:51-100,:178). The adapter subscribes toonChangeand resets on transition -deactivate -> reset('deactivate'), new generation-> reset('restart')(src/air/action-input.ts:325-330).SceneStackdefaultsmaxCachedPagesto 4 and reads the block canvas fromdocument.getElementById('GameCanvas')when none is passed (src/air/scene-stack.ts:61-63). DuringtransitionMsboth the new and the previous page stay active (dual-page window) and a capture-phase listener callsstopImmediatePropagation()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 bypop()(src/air/scene-stack.ts:145-152).- Audio autoplay unlock is an engine/browser policy concern:
AudioServicesurfaces an un-unlocked play as a non-advancingcurrentTimerather than throwing (src/air/audio-service.ts:11-12), and asystemEvent/inputgesture 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).