New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-hotkey-hook

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hotkey-hook

A react hook which can execute any function for any keyboard shortcut.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
333
-9.02%
Maintainers
1
Weekly downloads
 
Created
Source

React Hotkey Hook

A react hook which can execute any function for any keyboard shortcut.

Installation

Install the package with npm or yarn with either of the following commands.

npm i react-hotkey-hook
yarn add react-hotkey-hook

Make sure to import the useHotkey hook from the library after it is installed

import useHotkey from "react-hotkey-hook";

Usage

import "./App.css";
import React from "react";
import useHotkey from "react-hotkey-hook";

function App() {
  const onKeyPress = () => {
    console.log("key pressed");
  };

  useHotkey("Control+a", true, onKeyPress);

  useHotkey("Shift+A", true, onKeyPress);

  return (
    <div className="container">
      <h1>Example for React Hotkey Hook</h1>
    </div>
  );
}

export default App;

Options

All options are optional and have a default value which you can override to change the behavior of the hook.

OptionTypeDescription
hotkeysstringThe combination of hotkeys.
overidebooleanOptional Parameter. Prevents default event when true. True on default.
callback() => voidFunction that will be called when the combination of keys are pressed.

License

Distributed under the MIT License. See LICENSE for more information.

Keywords

react

FAQs

Package last updated on 14 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts