useKeyCombo

Events

A React hook that detects when a specific combination of keys is pressed simultaneously, useful for implementing keyboard shortcuts and hotkeys.

Installation

npm install @thibault.sh/hooks

API Reference

Signature


type KeyCombo = string[];

function useKeyCombo(targetCombo: KeyCombo): boolean

Parameters

NameTypeDescriptionDefault
targetCombo
KeyCombo (string[])
Array of key names that make up the combination.-

Returns

boolean

Boolean indicating if all keys in the combination are currently pressed.