# AppHotkeysController

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

Defined in: [controllers/app-hotkeys.ts:48](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L48)

A Lit ReactiveController for app hotkeys provided with `provideAppHotkeys`:
the effective app hotkeys, a cheat sheet list with live status, and the
user's custom hotkeys. Requests an update when any of them change.

## Example

```ts
class CheatSheet extends LitElement {
  private app = new AppHotkeysController(this)

  render() {
    return html`<ul>
      ${this.app.list.map(
        ({ appHotkey, status }) => html`<li>${appHotkey.meta?.name}: ${status}</li>`,
      )}
    </ul>`
  }
}
```

## Implements

- `ReactiveController`
- `CustomHotkeyActions`

## Constructors

### Constructor

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

Defined in: [controllers/app-hotkeys.ts:53](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L53)

#### Parameters

##### \_host

`ReactiveControllerHost`

#### Returns

`AppHotkeysController`

## Accessors

### appHotkeys

#### Get Signature

```ts
get appHotkeys(): RegisteredAppHotkeys;
```

Defined in: [controllers/app-hotkeys.ts:58](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L58)

Effective app hotkeys, typed by `Register`.

##### Returns

`RegisteredAppHotkeys`

***

### customHotkeys

#### Get Signature

```ts
get customHotkeys(): CustomHotkeys;
```

Defined in: [controllers/app-hotkeys.ts:68](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L68)

The user's hotkeys that differ from the defaults.

##### Returns

`CustomHotkeys`

***

### list

#### Get Signature

```ts
get list(): RegisteredAppHotkeyListItem[];
```

Defined in: [controllers/app-hotkeys.ts:63](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L63)

Every app hotkey with its live status, in declaration order.

##### Returns

`RegisteredAppHotkeyListItem`[]

## Methods

### dispose()

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

Defined in: [controllers/app-hotkeys.ts:130](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L130)

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`

***

### findConflicts()

```ts
findConflicts(
   id, 
   hotkey, 
   recordedWith?
): AppHotkey<string, HotkeyChord | HotkeySequence | null>[];
```

Defined in: [controllers/app-hotkeys.ts:100](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L100)

Other app hotkeys that would collide if `id` used `hotkey`. Pass the
recorder's `context` for a recorded hotkey: it has the key press, which
also finds a hotkey written differently that the same press fires.

#### Parameters

##### id

`string`

##### hotkey

`Hotkey`

##### recordedWith?

`RecordedKeyPresses`

#### Returns

`AppHotkey`\<`string`, `HotkeyChord` \| `HotkeySequence` \| `null`\>[]

#### Implementation of

```ts
CustomHotkeyActions.findConflicts
```

***

### hostConnected()

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

Defined in: [controllers/app-hotkeys.ts:108](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L108)

Called when the host is connected to the component tree. For custom
element hosts, this corresponds to the `connectedCallback()` lifecycle,
which is only called when the component is connected to the document.

#### Returns

`void`

#### Implementation of

```ts
ReactiveController.hostConnected
```

***

### hostDisconnected()

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

Defined in: [controllers/app-hotkeys.ts:121](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L121)

Called when the host is disconnected from the component tree. For custom
element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
which is called the host or an ancestor component is disconnected from the
document.

#### Returns

`void`

#### Implementation of

```ts
ReactiveController.hostDisconnected
```

***

### resetCustomHotkey()

```ts
resetCustomHotkey(id): void;
```

Defined in: [controllers/app-hotkeys.ts:86](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L86)

Restores the default hotkey for an app hotkey.

#### Parameters

##### id

`string`

#### Returns

`void`

#### Implementation of

```ts
CustomHotkeyActions.resetCustomHotkey
```

***

### resetCustomHotkeys()

```ts
resetCustomHotkeys(): void;
```

Defined in: [controllers/app-hotkeys.ts:91](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L91)

Restores every default hotkey.

#### Returns

`void`

#### Implementation of

```ts
CustomHotkeyActions.resetCustomHotkeys
```

***

### setCustomHotkey()

```ts
setCustomHotkey(
   id, 
   hotkey, 
   recordedWith?
): AppHotkey<string, HotkeyChord | HotkeySequence | null>[];
```

Defined in: [controllers/app-hotkeys.ts:77](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L77)

Sets the user's hotkey for an app hotkey. `null` unbinds it.
Returns conflicting app hotkeys; when any exist, nothing changes. Pass
the recorder's `context` for a recorded hotkey, as for `findConflicts`.

#### Parameters

##### id

`string`

##### hotkey

`Hotkey` \| `null`

##### recordedWith?

`RecordedKeyPresses`

#### Returns

`AppHotkey`\<`string`, `HotkeyChord` \| `HotkeySequence` \| `null`\>[]

#### Implementation of

```ts
CustomHotkeyActions.setCustomHotkey
```
