Skip to content

Doberjohn/usekeypress

Repository files navigation

@johnfanidis/usekeypress

npm (scoped) npm bundle size (minified)

React keypress hook.

Install

$ npm install @johnfanidis/usekeypress

Usage

import useKeyPress from "@johnfanidis/usekeypress";

const MyComponent = () => {
    
    // Sets up the hook listening for the 'S' key
    const pressed_V_Key = useKeyPress(83, true);

    useEffect(() => {
        if (pressed_S_Key) {
            // do something when 'S' key is pressed
        }
    }, [pressed_S_Key]);
    
  return null;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors