# Class: Input\<A\>

Defined in: [input.ts:54](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L54)

Action-based input across keyboard, pointer and gamepad.

```ts
const input = new Input(game, {
  bindings: { left: ["ArrowLeft", "KeyA", "PadLeft"], jump: ["Space", "PadA", "Pointer"] },
});
if (input.pressed("jump")) jump();
const dx = input.axis("left", "right");
```

Edges are cleared automatically after each simulation step.

## Type Parameters

### A

`A` *extends* `string`

## Constructors

### Constructor

> **new Input**\<`A`\>(`host`, `options`): `Input`\<`A`\>

Defined in: [input.ts:73](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L73)

#### Parameters

##### host

[`InputHost`](../interfaces/InputHost.md)

##### options

[`InputOptions`](../interfaces/InputOptions.md)\<`A`\>

#### Returns

`Input`\<`A`\>

## Properties

### bindings

> `readonly` **bindings**: [`Bindings`](../type-aliases/Bindings.md)\<`A`\>

Defined in: [input.ts:62](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L62)

The current bindings: Input's own copy of the options' map, read on every call. Change them with
`rebind()`, which keeps `keys.captured` in step.

***

### keys

> `readonly` **keys**: [`Keyboard`](Keyboard.md)

Defined in: [input.ts:55](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L55)

***

### pads

> `readonly` **pads**: [`Gamepads`](Gamepads.md)

Defined in: [input.ts:57](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L57)

***

### pointer

> `readonly` **pointer**: [`Pointer`](Pointer.md)

Defined in: [input.ts:56](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L56)

***

### virtual

> `readonly` **virtual**: `Map`\<`string`, [`ButtonState`](../interfaces/ButtonState.md)\>

Defined in: [input.ts:67](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L67)

Sources other code sets each step, by binding name: `TouchControls` writes `"TouchStickLeft"`, `"TouchA"` and
so on here. A binding found in this map reads from it instead of the keyboard.

## Methods

### axis()

> **axis**(`negative`, `positive`): `number`

Defined in: [input.ts:146](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L146)

-1, 0 or 1 from two opposing actions, e.g. `axis("left", "right")`.

#### Parameters

##### negative

`A`

##### positive

`A`

#### Returns

`number`

***

### dispose()

> **dispose**(): `void`

Defined in: [input.ts:150](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L150)

#### Returns

`void`

***

### down()

> **down**(`action`): `boolean`

Defined in: [input.ts:95](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L95)

Any binding for the action is held.

#### Parameters

##### action

`A`

#### Returns

`boolean`

***

### pressed()

> **pressed**(`action`): `boolean`

Defined in: [input.ts:108](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L108)

The action started this step.

#### Parameters

##### action

`A`

#### Returns

`boolean`

***

### rebind()

> **rebind**(`action`, `keys`): `void`

Defined in: [input.ts:138](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L138)

Replace an action's bindings, e.g. from a controls menu: `input.rebind("jump", ["KeyK", "PadA"])`.
Takes a copy of `keys`, and updates `keys.captured` so the new keys stop scrolling the page and the old
ones scroll it again.

#### Parameters

##### action

`A`

##### keys

readonly `string`[]

#### Returns

`void`

***

### released()

> **released**(`action`): `boolean`

Defined in: [input.ts:121](https://github.com/debuffjp/debuff/blob/4f0ae1091cc5ab837e28b1efc93d4aed7342f621/packages/input/src/input.ts#L121)

The action ended this step.

#### Parameters

##### action

`A`

#### Returns

`boolean`
