# VirtualInput

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Not replicated
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/VirtualInput/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/VirtualInput

Simulates mouse, keyboard, and pointer input as if it were performed by a real player.

## Methods

### SendKey

```luau
VirtualInput:SendKey(isPressed: boolean, keyCode: Enum.KeyCode, isRepeatedKey: boolean? = false)
```

Injects a keyboard key press or release event.

Parameters:

- `isPressed`: Whether to simulate a key press (`true`) or a key release (`false`).
- `keyCode`: The `KeyCode` of the key to inject.
- `isRepeatedKey`: Whether this is an auto-repeat event, as occurs when a key is held down. Only valid for text-manipulation keys such as `KeyCode.Backspace`, `KeyCode.Delete`, and the arrow keys. Defaults to `false`.

### SendMouseButton

```luau
VirtualInput:SendMouseButton(position: Vector2, button: Enum.UserInputType, isDown: boolean, repeatCount: number? = 0)
```

Injects a mouse button press or release event at the specified screen position.

Parameters:

- `position`: The screen-space position in pixels at which to inject the event.
- `button`: The mouse button to use. Supported values are `UserInputType.MouseButton1`, `UserInputType.MouseButton2`, and `UserInputType.MouseButton3`.
- `isDown`: Whether to simulate a button press (`true`) or a button release (`false`).
- `repeatCount`: The consecutive-click count for multi-click detection, such as a double- or triple-click. Defaults to `0`.

### SendMouseDelta

```luau
VirtualInput:SendMouseDelta(positionDelta: Vector2)
```

Injects a relative mouse movement event. Only works while the player's cursor is locked.

Parameters:

- `positionDelta`: The relative mouse movement in pixels along each axis.

### SendMousePosition

```luau
VirtualInput:SendMousePosition(position: Vector2)
```

Moves the virtual mouse cursor to the specified absolute screen position.

Parameters:

- `position`: The target screen-space position in pixels.

### SendPointerAction

```luau
VirtualInput:SendPointerAction(position: Vector2, pointerAction: { [string]: any })
```

Injects a scroll wheel, trackpad pan, or pinch gesture event at the specified screen position.

Parameters:

- `position`: The screen-space position in pixels at which to inject the event.
- `pointerAction`: A dictionary describing the pointer action to inject. Accepted keys are `Wheel` (number), `Pan` ([`Vector2`](https://rapi.sleaze.dev/index/types/Vector2.md)), and `Pinch` (number). At least one key must have a non-zero value.

### SendTextInput

```luau
VirtualInput:SendTextInput(text: string)
```

Injects a text input event as if the specified string was typed on a keyboard.

Parameters:

- `text`: The string to inject as text input.

## Inherited members

- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
