useKeyCombo
Hook to detect if a specified key combination is pressed.
Usage
Live Editor
function App() { const isCtrlShiftPressed = useKeyCombo(["Control", "Shift"]); return ( <div> <h1>Press the Ctrl + Shift keys</h1> {isCtrlShiftPressed && <p>Ctrl + Shift keys are pressed!</p>} </div> ); }
Result
Loading...
API
Parameter
keys
:string[]
- An array of keys to detect.
Returns : boolean
A boolean indicating if the specified key combination is pressed or not.