{"library":"react-hotkeys-hook","title":"react-hotkeys-hook","description":"A React hook for declaratively handling keyboard shortcuts in components. Current stable version is 5.3.0, released with monthly cadence. It ships TypeScript definitions, supports scopes to prevent hotkey collisions, focus traps, and enables/disables scopes via context. Unlike alternatives like react-hotkeys (maintenance mode) or mousetrap (no React hook), this library is React-first with a simple hook API. Requires React >= 16.8.0. Bundle size is minimal (~2KB gzipped). ESM and CJS exports available.","language":"javascript","status":"active","last_verified":"Fri May 01","install":{"commands":["npm install react-hotkeys-hook"],"cli":null},"imports":["import { useHotkeys } from 'react-hotkeys-hook'","import { useHotkeysContext } from 'react-hotkeys-hook'","import { HotkeysProvider } from 'react-hotkeys-hook'","import { isHotkeyPressed } from 'react-hotkeys-hook'","import type { Options } from 'react-hotkeys-hook'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import React, { useState } from 'react';\nimport { useHotkeys } from 'react-hotkeys-hook';\n\nconst Example = () => {\n  const [count, setCount] = useState(0);\n  useHotkeys('ctrl+k', () => setCount(c => c + 1), { scopes: ['global'] }, [count]);\n  return <p>Pressed {count} times.</p>;\n};\n\nexport default Example;","lang":"typescript","description":"Basic example using useHotkeys with a scope dependency array. Shows increment on Ctrl+K press.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}