---
agentTools:
  projectIndex: https://docs.rainway.com/llms.txt
---

# Web SDK - StreamEvents."before-input"

[Home](https://docs.rainway.com/reference/about) > [@rainway/web](web-sdk) > [StreamEvents](./web-sdk-streamevents) > ["before-input"](./web-sdk-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](./web-sdk-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:

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

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.

<b>Signature:</b>

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