Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Mohammad Khanafi thekingofbandit

💭
I may be slow to respond.
View GitHub Profile
View use-key-press-example.jsx
import { useState, useEffect } from 'react';
// Usage
function App() {
// Call our hook for each key that we'd like to monitor
const happyPress = useKeyPress('h');
const sadPress = useKeyPress('s');
const robotPress = useKeyPress('r');
const foxPress = useKeyPress('f');