Web SDK - StreamEvents."before-input"

Home > @rainway/web > StreamEvents > "before-input"

StreamEvents."before-input" property

Raised when an input (keyboard, mouse, gamepad...) is about to be sent to the remote device.

Only input attempts enabled by the stream's InputLevel cause beforeinput events.

You can listen to this event and call event.preventDefault() to apply a fine-grained input filter, or respond to key combinations. Example:

myStream.addEventListener("beforeinput", (event) => {
    const { input, heldKeys } = event;
    if (input.type === "keyboard" && input.key === VirtualKey.Q) {
        // Block the input, but send a message instead.
        if (input.action === KeyboardAction.Down) {

This should not be used to prevent security-sensitive key combinations like Alt+Tab. Instead, the remote host can filter _incoming_ inputs. See https://docs.rainway.com/docs/input-filtering for more info.


"before-input": (input: RainwayInputEvent) => void | Promise<void>;