Socket
Socket
Sign inDemoInstall

react-konamikey

Package Overview
Dependencies
3
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-konamikey

💅 trigger a callback function on anything with a sequence of key presses


Version published
Weekly downloads
7
Maintainers
1
Install size
231 kB
Created
Weekly downloads
 

Readme

Source

react-konamikey CircleCI

Trigger a callback function on anything with a sequence of key presses.

Install

# requires react@>=16
yarn add react-konamikey

Usage

import * as React from 'react'
import Konami from 'react-konamikey'
// const Konami = require('react-konamikey').default

attach to an element (using refFn)

<Konami
  element={({ refFn }) => (
    <input type="text" placeholder="gamma" ref={refFn} />
  )}
  payload={() => console.log('KONAMI!!!')}
  sequence={['g', 'a', 'm', 'm', 'a']}
/>

attach to document

<Konami
  element={document}
  payload={() => console.log('KONAMI!!!')}
  sequence={['a', 'b', 'c']}
>
  <div>hello world</div>
</Konami>

live example

https://codesandbox.io/s/blissful-pare-c7hvb

Props

element

Type: HTMLElement | Function

An HTMLElement, document, or function to attach keydown event handlers to.

payload

Type: Function

A payload function to execute, once the Konami sequence has been fulfilled.

sequence

Type: Array [required]

An array of strings representing key names.

License

MIT

Keywords

FAQs

Last updated on 22 Jan 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc