# HeldKeyCodesController

<!-- DO NOT EDIT: this page is autogenerated from the type comments -->

Defined in: [controllers/held-key-codes.ts:28](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/held-key-codes.ts#L28)

A Lit ReactiveController that tracks all currently held key names to their physical `event.code` values.

Subscribes to the global KeyStateTracker and triggers host updates
whenever keys are pressed or released.

## Example

```ts
class KeyDisplay extends LitElement {
  private heldKeyCodes = new HeldKeyCodesController(this)

  render() {
    const heldCodes = Object.entries(this.heldKeyCodes.value).map(([key, code]) => `${key}: ${code}`).join(' + ')
    return html`
      <div>
        Currently pressed: ${heldCodes || 'None'}
      </div>
    `
  }
}
```

## Implements

- `ReactiveController`

## Constructors

### Constructor

```ts
new HeldKeyCodesController(_host): HeldKeyCodesController;
```

Defined in: [controllers/held-key-codes.ts:42](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/held-key-codes.ts#L42)

#### Parameters

##### \_host

`ReactiveControllerHost`

The Lit component that owns this controller.

#### Returns

`HeldKeyCodesController`

## Accessors

### value

#### Get Signature

```ts
get value(): Record<string, string>;
```

Defined in: [controllers/held-key-codes.ts:35](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/held-key-codes.ts#L35)

Map of currently held key names to their physical `event.code` values.

##### Returns

`Record`\<`string`, `string`\>

## Methods

### dispose()

```ts
dispose(): void;
```

Defined in: [controllers/held-key-codes.ts:76](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/held-key-codes.ts#L76)

Releases the controller now and removes it from its host. Use it to
remove a controller early: Lit's `removeController` alone leaves it active.

#### Returns

`void`

***

### hostConnected()

```ts
hostConnected(): void;
```

Defined in: [controllers/held-key-codes.ts:47](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/held-key-codes.ts#L47)

Subscribes to the tracker store and updates the internal state when changes occur.

#### Returns

`void`

#### Implementation of

```ts
ReactiveController.hostConnected
```

***

### hostDisconnected()

```ts
hostDisconnected(): void;
```

Defined in: [controllers/held-key-codes.ts:66](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/held-key-codes.ts#L66)

Unsubscribes from the tracker store and stops tracking the held key codes.

#### Returns

`void`

#### Implementation of

```ts
ReactiveController.hostDisconnected
```
