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

parseKeyboardEvent

ts
function parseKeyboardEvent(event, platform?): ParsedHotkeyChord;
function parseKeyboardEvent(event, platform?): ParsedHotkeyChord;

Defined in: parse.ts:308

Parses a KeyboardEvent into the chord it pressed, in the same format as parseHotkey(). Pass the result to normalizeHotkey for its canonical string.

Parameters

event

KeyboardEvent

The KeyboardEvent to parse

platform?

Platform

The target platform for resolving modifiers (defaults to auto-detection)

Returns

ParsedHotkeyChord

The parsed chord for the keyboard event

Example

ts
document.addEventListener('keydown', (event) => {
  const parsed = parseKeyboardEvent(event)
  console.log(parsed) // { key: 'S', ctrl: true, shift: false, ... }
})
document.addEventListener('keydown', (event) => {
  const parsed = parseKeyboardEvent(event)
  console.log(parsed) // { key: 'S', ctrl: true, shift: false, ... }
})