Huge News!Announcing our $40M Series B led by Abstract Ventures.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
  • Socket score

Version published
Weekly downloads
257
decreased by-30.73%
Maintainers
1
Weekly downloads
 
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc