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
Hotkeys API Reference
App Hotkeys API Reference
Key hold & held keys API Reference
Hotkey Recorder API Reference
Normalization & format API Reference
Normalization & format API Reference

validateHotkey

ts
function validateHotkey(hotkey): ValidationResult;
function validateHotkey(hotkey): ValidationResult;

Defined in: validate.ts:36

Validates a hotkey and returns any warnings or errors. Sequences are validated step by step, and messages name the failing step.

Checks for:

  • Valid syntax (modifier+...+key format)
  • Known modifiers
  • Known keys

Parameters

hotkey

ValidatableHotkey

The hotkey string to validate

Returns

ValidationResult

A ValidationResult with validity status, warnings, and errors

Example

ts
validateHotkey('Mod+S')
// { valid: true, warnings: [], errors: [] }

validateHotkey('')
// { valid: false, warnings: [], errors: ['Hotkey cannot be empty'] }

validateHotkey(['G', 'Foo+H'])
// { valid: false, warnings: [], errors: ["Step 2: Unknown modifier: 'Foo'"] }
validateHotkey('Mod+S')
// { valid: true, warnings: [], errors: [] }

validateHotkey('')
// { valid: false, warnings: [], errors: ['Hotkey cannot be empty'] }

validateHotkey(['G', 'Foo+H'])
// { valid: false, warnings: [], errors: ["Step 2: Unknown modifier: 'Foo'"] }