# use-konami-code

> useKonamiCode React Hook.

Latest version **1.0.1** (published 2020-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-konami-code
pnpm add use-konami-code
yarn add use-konami-code
bun add use-konami-code
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-05-26 |
| First published | 2020-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | James Perih, Four and a Half Giraffes, Ltd. |
| Maintainers | hotdang-ca |
| Keywords | konami, code, cheat, cheatcode, keyboard, sequence |

## Links

- npm: https://www.npmjs.com/package/use-konami-code
- Repository: https://github.com/hotdang-ca/use-konami-code
- Homepage: https://github.com/hotdang-ca/use-konami-code#readme
- Issues: https://github.com/hotdang-ca/use-konami-code/issues
- npm.io page: https://npm.io/package/use-konami-code

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-05-26

## README

# Konami Code React Hook

## What is it?
Allows you to `useKonamiCode` to listen in on any React Functional Component for the Konami Code sequence. Provide an `onSuccess` and `onFail` callback.

Eg:
```js
import { useKonamiCode } from 'use-konami-code';
import { useState } from 'react';

const HomeComponent: React.FC<any> = () => {
    const [ message, setMessage ] = useState('');
    useKonamiCode(() => {
        setMessage('You did it!');
    }, () => {
        setMessage('');
    });

    return (
        <div>
            { message && <span>{message}</span> }
        </div>
    )
}
```

## Custom Code Sequence
You can also provide an alternate code sequence, a `String[]` consisting of JavaScript Event Keycodes, as a third parameter, eg:

```js
    const alternateKonamiCode = ['ArrowUp', 'ArrowUp', 'ArrowDown', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'ArrowLeft', 'ArrowRight', 'b', 'a', 'b', 'a', 'Enter'];

    useKonamiCode(() => {
        setMessage('you do remember!');
    }, () => {
        setMessage('');
    }, alternateKonamiCode);
```
Try [Keycode.info](https://keycode.info) to set up your own code.

## What is the Konami Code?
From [Wikipedia](https://en.wikipedia.org/wiki/Konami_Code):
> The Konami Code (Japanese: コナミコマンド, Konami komando, "Konami command") is a cheat code that appears in many Konami video games, and some non-Konami games. In the original code, the player can press the following sequence of buttons on the game controller to enable a cheat or other effects:
> 
> ↑ ↑ ↓ ↓ ← → ← → B A

## Author
James Perih @ Four And A Half Giraffes, Ltd.

---
_Source: https://npm.io/package/use-konami-code · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
