# Connection: input property

> The input read-only property of the Connection interface is the input the room applied for the connection's player this tick.

The **`input`** read-only property of the [`Connection`](/docs/room/connection) interface is the input the room applied for the connection's player this tick.

## Value

The input as the stepper's `parseInput()` returned it, typed `unknown`, or `undefined`.

- It's set before the stepper runs and cleared after `onTick`, so the stepper and `onTick` both see it.
- It's `undefined` when the player sent no input for this tick, in a room without a stepper, and at any time between ticks, such as in `onMessage`.

## Description

Inputs go to the stepper, which runs on the room and in the player's client to predict it. Act on the parts the room alone decides, such as a shot or a pickup, in `onTick`, where `input` is still set, together with the [`viewTick`](/docs/room/connection/viewtick) the input was sent from.

A stepper without `parseInput()` passes the input on as the client sent it, so check it before trusting it.

## Examples

### Spending ammo on the ticks a player fires

```ts
// ammo.ts
import { defineRoom, defineSchema, defineStepper, entity } from "@irtio/room";

const Gunner = entity("gunner", { owner: "string", angle: "angle", ammo: "u8" }, { key: "owner" });
type Input = { turn: number; fire: boolean };

const stepper = defineStepper<Input>({
  parseInput(raw) {
    const { turn, fire } = raw as { turn?: unknown; fire?: unknown };
    if (typeof turn !== "number" || Math.abs(turn) > 1 || typeof fire !== "boolean") throw new TypeError("input is { turn, fire }");
    return { turn, fire };
  },
  step(world, inputs, dt) {
    for (const gunner of world.all(Gunner)) gunner.angle += (inputs.get(gunner.owner)?.turn ?? 0) * 3 * dt;
  },
});

export default defineRoom({
  tickRate: 30,
  schema: defineSchema({ entities: [Gunner] }),
  stepper,
  onJoin(room, connection) {
    if (!room.entities.get(Gunner, connection.player)) room.entities.create(Gunner, { owner: connection.player, ammo: 30 });
  },
  onTick(room) {
    for (const connection of room.connections.values()) {
      const gunner = room.entities.get(Gunner, connection.player);
      if (!gunner || !(connection.input as Input | undefined)?.fire || gunner.ammo === 0) continue;
      gunner.ammo -= 1;
      room.broadcast({ type: "shot", from: connection.player, angle: gunner.angle }, { unreliable: true });
    }
  },
});
```

## See also

- [`Connection.viewTick`](/docs/room/connection/viewtick)
- [Prediction](/docs/client/prediction)
- [Lag compensation](/docs/room/guides/lag-compensation)
