New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@react-typed-hooks/use-key-press

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-typed-hooks/use-key-press

React hook written in TypeScript

1.0.5
latest
Source
npm
Version published
Maintainers
1
Created
Source

useKeyPress

React hook that returns true when the specified targetKey is pressed.

version

Installation

npm install @react-typed-hooks/use-key-press

Usage

import { useKeyPress } from "@react-typed-hooks/use-key-press";

const Demo = () => {
  const isEscapePressed = useKeyPress({ targetKey: "Escape" });

  return isEscapePressed ? "Yes" : "No";
};

API

Types

interface UseKeyPressOptions {
  targetKey: KeyboardEvent["key"];
}
function useKeyPress(options: UseKeyPressOptions): boolean;

Options

targetKey: KeyboardEvent["key"]

A predefined key value (i.e, Escape, Enter, Backspace, etc) to watch the keydown and keyup event on.

Keywords

react

FAQs

Package last updated on 06 Dec 2020

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