Handling pointer and keyboard input — native DOM events inside the plugin frame, and events forwarded from the host page
Because plugins run in a sandboxed iframe, they have direct access to the standard browser event system inside that frame. For most interactive plugins, native DOM event listeners are all you need.
The SDK also provides a forwarded event channel for input that originates outside the plugin frame but that the host decides to relay — useful for plugins that need to respond to global keyboard shortcuts or host-page gestures.
The plugin frame is a full browser document. Attach event listeners directly to your DOM elements using standard browser APIs:
Every standard browser event API is available: pointer events, touch events, mouse events, wheel events, drag events. If your plugin renders a React component tree, use React's synthetic event system as you normally would.
The plugin frame does not receive keyboard events unless it has focus. If your plugin needs keyboard input, request focus when the student first interacts with it:
The sandbox permits the Pointer Lock API (allow-pointer-lock). Use it in plugins that need unrestricted mouse movement — 3D navigators, drawing tools, first-person simulations:
Registers a handler for pointer events forwarded from the host page — events that occurred on the internote page outside the plugin frame but which the runtime has relayed to the plugin.
handler (function; required). Called with a PluginPointerEvent object.voidonPointer receives events that originate outside the plugin frame. For events the student makes directly inside the plugin frame, use native addEventListener on your DOM elements — those events are richer and already properly scoped.
Registers a handler for keyboard events forwarded from the host page. Useful when the plugin should respond to keyboard input even when its frame does not have focus — for example, advancing a simulation step in sync with the student navigating the internote.
handler (function; required). Called with a PluginKeyboardEvent object.voidTouch events and the Pointer Events API both work natively in the plugin frame. The Pointer Events API is recommended over the raw Touch Events API because it handles both mouse and touch with a unified interface:
setPointerCapture ensures that pointermove and pointerup events are delivered to the canvas even if the pointer leaves its bounds during a drag — particularly important on touch devices.