> ## 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

# Class: KeyboardController

Defined in: [index.d.ts:604](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L604)

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.

## Constructors

### Constructor

> **new KeyboardController**(): `KeyboardController`

Defined in: [index.d.ts:605](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L605)

#### Returns

`KeyboardController`

## Methods

### key()

> **key**(`key`, `direction`): `void`

Defined in: [index.d.ts:619](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L619)

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

##### key

[`Key`](../enumerations/Key.mdx)

##### direction

[`Direction`](../enumerations/Direction.mdx)

#### Returns

`void`

***

### keyOther()

> **keyOther**(`value`, `direction`): `void`

Defined in: [index.d.ts:623](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L623)

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

#### Parameters

##### value

`number`

##### direction

[`Direction`](../enumerations/Direction.mdx)

#### Returns

`void`

***

### keyUnicode()

> **keyUnicode**(`value`, `direction`): `void`

Defined in: [index.d.ts:621](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L621)

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

#### Parameters

##### value

`string`

##### direction

[`Direction`](../enumerations/Direction.mdx)

#### Returns

`void`

***

### raw()

> **raw**(`keycode`, `direction`): `void`

Defined in: [index.d.ts:635](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L635)

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

##### keycode

`number`

##### direction

[`Direction`](../enumerations/Direction.mdx)

#### Returns

`void`

***

### text()

> **text**(`text`): `void`

Defined in: [index.d.ts:611](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L611)

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

##### text

`string`

#### Returns

`void`
