In the test page the user can trigger the code to run by pressing Shift+R from the Blockly workspace, or by pressing the "run code" button. In either case the p5.js context should receive following key-presses.
For testing purposes I'm making an "on space pressed" block that can trigger actions in the p5 context.
In the broader scope, most blockly-based applications have a code workspace and a runtime. Many of them expect interaction with the runtime: micro:bit has a simulator that can be clicked and tilted, code.org has clicking in flappy bird, and so on. That means we need to have a standard way to move between the workspace and the runtime, since we don't want keypresses aimed at (e.g.) playing a game in the runtime to actually move blocks around in the blockly workspace.
In the test page the user can trigger the code to run by pressing
Shift+R
from the Blockly workspace, or by pressing the "run code" button. In either case the p5.js context should receive following key-presses.For testing purposes I'm making an "on space pressed" block that can trigger actions in the p5 context.
In the broader scope, most blockly-based applications have a code workspace and a runtime. Many of them expect interaction with the runtime: micro:bit has a simulator that can be clicked and tilted, code.org has clicking in flappy bird, and so on. That means we need to have a standard way to move between the workspace and the runtime, since we don't want keypresses aimed at (e.g.) playing a game in the runtime to actually move blocks around in the blockly workspace.