Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
API Reference
Hotkeys API Reference
Hotkey Sequence API Reference
Key hold & held keys API Reference
Hotkey Recorder API Reference
Hotkey Sequence Recorder API Reference
Normalization & format API Reference
Hotkeys API Reference

hotkey

Function: hotkey()

ts
function hotkey(hotkey, options): <T>(proto, propertyKey, descriptor?) => void;
function hotkey(hotkey, options): <T>(proto, propertyKey, descriptor?) => void;

Defined in: decorators/hotkey.ts:29

Decorator that registers a keyboard hotkey on the element when it connects and unregisters when it disconnects. Uses HotkeyController under the hood.

Parameters

hotkey

RegisterableHotkey

The key or key combo to listen for (e.g. 'Mod+S' or a raw hotkey object).

options

HotkeyOptions = HOTKEY_DEFAULT_OPTIONS

Optional registration options (target, platform, enabled, etc.).

Returns

A method decorator for use on LitElement methods.

ts
<T>(
   proto, 
   propertyKey, 
   descriptor?): void;
<T>(
   proto, 
   propertyKey, 
   descriptor?): void;

Type Parameters

T

T extends HotkeyCallback

Parameters

proto

LitElement

propertyKey

string

descriptor?

TypedPropertyDescriptor<T>

Returns

void

Example

ts
class MyElement extends LitElement {
  @hotkey('Mod+S')
  save() { this.doSave() }

  @hotkey('Escape')
  close() { this.dismiss() }
}
class MyElement extends LitElement {
  @hotkey('Mod+S')
  save() { this.doSave() }

  @hotkey('Escape')
  close() { this.dismiss() }
}