> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simular.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# KeyboardController

> Contains functions to simulate key presses/releases and to input text.

For entering text, the `text` method is best. If you want to enter
a key without having to worry about the layout or the keymap, use
the `key` method. If you want a specific (physical) key to be
pressed (e.g WASD for games), use the `raw` method. The resulting
keysym will depend on the layout/keymap.

## Constructor

```typescript
KeyboardController(): KeyboardController
```

### Returns

`KeyboardController`

## Methods

### key()

```typescript
key(key: Key, direction: Direction): void
```

Sends an individual key event. It will enter the keysym (virtual
key). Have a look at the `raw` method, if you want to enter a
keycode.

Some of the keys are specific to a platform.

#### Parameters

<ResponseField name={"key"} type={"Key"} required />

<ResponseField name={"direction"} type={"Direction"} required />

### keyOther()

```typescript
keyOther(value: number, direction: Direction): void
```

Sends a key event for a raw, platform-specific key value.

#### Parameters

<ResponseField name={"value"} type={"number"} required />

<ResponseField name={"direction"} type={"Direction"} required />

### keyUnicode()

```typescript
keyUnicode(value: string, direction: Direction): void
```

Sends an individual Unicode key event. Provide a single character.

#### Parameters

<ResponseField name={"value"} type={"string"} required />

<ResponseField name={"direction"} type={"Direction"} required />

### raw()

```typescript
raw(keycode: number, direction: Direction): void
```

Sends a raw keycode. The keycode may or may not be mapped on the
current layout. You have to make sure of that yourself. This can
be useful if you want to simulate a press regardless of the layout
(WASD on video games). Have a look at the `key` method, if you
just want to enter a specific key and don't want to worry about
the layout/keymap. Windows only: If you want to enter the keycode
(scancode) of an extended key, you need to set the high byte for
the extended key too. You can for example do:
`raw(0xE01D, Direction.Click)` to simulate `RControl`.

#### Parameters

<ResponseField name={"keycode"} type={"number"} required />

<ResponseField name={"direction"} type={"Direction"} required />

### text()

```typescript
text(text: string): void
```

Enter the text. You can use unicode here like: ❤吅. This works regardless
of the current keyboard layout. You cannot use this function for entering
shortcuts or something similar. For shortcuts, use the `key` method instead.

#### Parameters

<ResponseField name={"text"} type={"string"} required />
