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

@daniel.husar/use-escape-key

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

@daniel.husar/use-escape-key

React hook for escape key press

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

use-escape-key

⚠️ Warning: hooks are not part of a stable React release yet, so use this library only for experiments

Demo

About

@danielhusar/use-escape-key is a react custom-hook that will execute function when escape key is pressed

Install

yarn add @daniel.husar/use-escape-key

API

useEscapeKey

This is a hook that lets you execute function when escape key is pressed.

Usage

import useEscapeKey from '@daniel.husar/use-escape-key';
const Component = (props) => {
  useEscapeKey(() => console.log('I have pressed escape key!'));
}

First argument in useEscapeKey is function that will be executed when escape key is pressed. The event object is passed into this function as argument.

Second optional argument is object for options:

window

Type: object Default: 'window object'

This is useful if you don't want to bind event to current window, but for example to parent window (window.parent)

dependencies

Type: array Default: []

If you use in your function any values from the outer scope that change over time, you should provide them as dependencies so function will get executed with latest values. This get passed as second argument into useEffect hook.

License

MIT © Daniel Husar

Keywords

FAQs

Package last updated on 29 Oct 2018

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