npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2026 โ€“ย Pkg Stats / Ryan Hefner

react-keybinder

v1.0.0

Published

๐Ÿš€ A simple React hook for handling keyboard shortcuts and keybindings effortlessly.

Readme

๐Ÿ“œ README.md

React KeyBinder

A lightweight React hook for handling keyboard shortcuts.

npm version
License: MIT


๐Ÿš€ Features

  • Easy keybinding for React applications
  • Supports both single keys and key combinations (e.g., Ctrl+S, Shift+K)
  • Works seamlessly with function components and hooks
  • Minimal and efficient

๐Ÿ“ฆ Installation

Install via npm or yarn:

npm install react-keybinder
# or
yarn add react-keybinder

๐Ÿ”ฅ Usage

Basic Keybinding

import { useKeyBinder } from "react-keybinder";

function App() {
    useKeyBinder("s", () => alert("S key pressed!"));
    return <div>Press "S" to see an alert.</div>;
}

Handling Key Combinations (e.g., Ctrl + S)

useKeyBinder("ctrl+s", (event) => {
    event.preventDefault();
    console.log("Saved!");
});

Binding Multiple Keys

useKeyBinder(["a", "b", "c"], () => console.log("A, B, or C was pressed"));

๐ŸŽ› API

useKeyBinder(keys: string | string[], callback: (event?: KeyboardEvent) => void);

| Parameter | Type | Description | |-----------|-------------------|---------------------------------------------------------------| | keys | string | string[] | The key(s) or key combinations to listen for ("s", "ctrl+s", ["a", "b"]) | | callback| function | The function to execute when the key is pressed |


๐Ÿ”ง Supported Key Combinations

  • Single keys ("s", "Enter", "ArrowUp", etc.)
  • Modifier keys (Ctrl, Shift, Alt, Meta)
  • Examples: "ctrl+s", "shift+k", "alt+enter"

๐Ÿ›  Contributing

Contributions are welcome! To contribute:

  1. Fork this repository.
  2. Create a feature branch:
    git checkout -b feature-name
  3. Commit changes:
    git commit -m "Added new feature"
  4. Push to GitHub and submit a Pull Request.

๐Ÿ“œ License

This project is licensed under the MIT License.