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 API Reference
Held Keys API Reference
Hotkey Recorder API Reference
Hotkey Sequence Recorder API Reference
Format for Display API Reference

parseKeyboardEvent

Function: parseKeyboardEvent()

ts
function parseKeyboardEvent(event): ParsedHotkey;

Defined in: parse.ts:208

Parses a KeyboardEvent into a ParsedHotkey object.

This function extracts the key and modifier state from a keyboard event and converts it into the same format used by parseHotkey().

Parameters

event

KeyboardEvent

The KeyboardEvent to parse

Returns

ParsedHotkey

A ParsedHotkey object representing the keyboard event

Example

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