# AppHotkeysController

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

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

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`

## Constructors

### Constructor

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

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

#### Parameters

##### \_host

`ReactiveControllerHost`

#### Returns

`AppHotkeysController`

## Accessors

### appHotkeys

#### Get Signature

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

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

Effective app hotkeys, typed by `Register`.

##### Returns

`RegisteredAppHotkeys`

***

### customHotkeys

#### Get Signature

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

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

The user's hotkeys that differ from the defaults.

##### Returns

`CustomHotkeys`

***

### list

#### Get Signature

```ts
get list(): AppHotkeyListItem<AppHotkey<string, HotkeyChord | HotkeySequence | null>>[];
```

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

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

##### Returns

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

## Methods

### dispose()

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

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

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:101](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L101)

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`\>[]

***

### hostConnected()

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

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

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:122](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L122)

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:87](https://github.com/TanStack/hotkeys/blob/main/packages/lit-hotkeys/src/controllers/app-hotkeys.ts#L87)

Restores the default hotkey for an app hotkey.

#### Parameters

##### id

`string`

#### Returns

`void`

***

### resetCustomHotkeys()

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

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

Restores every default hotkey.

#### Returns

`void`

***

### setCustomHotkey()

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

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

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`\>[]
