Add one point with Space
Key IDs use KeyboardEvent.code: KeyA, Digit1,
ArrowLeft, Space, or Enter.
TurboWarp extension · User guide
Async Input connects a physical key, a sprite tap, or an accumulated pose to a Temporary Variables runtime variable. Your project can read the latest value from any script—and optionally receive a broadcast at the same moment.
Kamishibai DSL 4.0 bundle
Under the Async Input member heading, use the documentation button. The bundled blocks retain the keyboard, sprite-tap, pose, runtime-variable, broadcast, ownership, and cleanup behavior described here; only their namespace and icon identify their origin inside the combined runtime.
Quick start
Register listeners when the project starts. Registration remembers what should happen; it does not wait for the input and it does not initialize the runtime variable for you.
Add Temporary Variables first. Then load Async Input as a custom extension with Run extension without sandbox enabled.
Use Temporary Variables to create a runtime variable, such as input or
score. Use 0 before arithmetic updates.
Put an Async Input “listen” block under when green flag clicked. The sprite, clone, or stage running the block owns that binding.
Matching input updates the runtime variable immediately. “And broadcast” blocks then start the named Scratch broadcast.
The runtime variable is always written before the optional broadcast starts.
Use the reviewed, version-pinned build:
@kubohiroya/turbowarp-async-input@0.4.0.
Examples
Key and touch blocks are included in the distributed build. Accumulated pose blocks are
optional and only appear in a build with the poseInput feature flag enabled.
Key IDs use KeyboardEvent.code: KeyA, Digit1,
ArrowLeft, Space, or Enter.
Only the topmost rendered sprite under the pointer matches. Transparent pixels and clones follow TurboWarp renderer behavior.
Requires TMPose with accumulated pose scoring and change events enabled. The binding runs when the active accumulated pose changes to the registered name.
Application integration
Version 0.3.0 adds a side-effect-free Composition API for controllers that need to await a pose, physical key, or topmost actor touch candidate.
Import @kubohiroya/turbowarp-async-input/composition and inject only the
pose, key, or actor-touch sources the controller uses. Importing it does not access
Scratch, the DOM, or the TurboWarp VM.
Pose, key, and actor-touch waits share one owner. Starting a valid wait aborts the
previous wait, and abort, completion, rejection, or releaseAll()
unsubscribes immediately.
Target ownership
Re-registering the same input from the same target replaces only that target’s binding. Other sprites and clones can listen for the same key or pose independently.
One KeyA press updates every matching target-owned binding.
Values
A value beginning with +, -, *, or /
is a compound arithmetic update. Any other value is assigned as exact text.
score8score10| VALUE | Effect | Starting value required |
|---|---|---|
+2 | Add 2 | Finite number |
-1 | Subtract 1 | Finite number |
*3 | Multiply by 3 | Finite number |
/2 | Divide by 2 | Finite number; non-zero divisor |
pressed | Set exact text | None |
Invalid or non-finite arithmetic leaves the current value unchanged and skips that binding’s broadcast.
Block reference
“Listen” blocks register or replace behavior and return immediately. “Stop” blocks only affect bindings owned by the target that runs them.
Troubleshooting
Open each item for the most common cause and the shortest fix.
Load TurboWarp’s Temporary Variables extension before Async Input, then start the project again. Async Input writes through that extension’s runtime-variable API.
Use the physical key code, not the typed character: KeyA, not
a; Digit1, not 1. Auto-repeat, IME composition,
and key presses inside editable controls are intentionally ignored.
Run a registration block from each sprite or clone that needs a listener. Only the renderer’s topmost picked sprite receives a pointer match, and the Stage is not valid for a “this sprite” touch listener.
Pose input is behind the independently reversible poseInput feature flag,
which is OFF in the distributed build. A pose-enabled build also needs TMPose with
accumulated scoring and change events enabled.
Initialize the runtime variable to a finite number. Missing values, non-numeric text, division by zero, overflow, and non-finite operands are rejected without changing the current value.
Starting or stopping the project clears all bindings by design. Register listeners under when green flag clicked so the intended bindings are recreated for each run.