kodenami
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

🕹 Kodenami - A Konami Code plugin

The Konami Code, also commonly referred to as the Contra Code and sometimes the 30 Lives code, 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 :

Konami Code

Features

✅ TypeScript support

Install

NPM

npm i kodenami

Yarn

yarn add kodenami

Usage

Parameters

Callback

  • The first parameter need to be a callback function.
  • This function will be called when the sequence is complete.

Options

  • The second parameter is an object of options (optional).
Code
  • An array of string which correspond to the expected sequence.
  • Default : the Konami code sequence (see image above).
Once
  • A boolean which defines whether the callback is only called once or not.
  • Default : true.

Example

// import it
import Kodenami from 'Kodenami';

// create a callback function
function callback() {
  console.log('Konami code : activated !');
}

// instantiate it
const kodenami = new Kodenami(callback, {
  code: ['ArrowUp', 'ArrowDown'],
  once: true, // default
});

// call it
window.addEventListener('keydown', event => {
  kodenami.use(event.key); // 'ArrowUp', ...
});

License

See LICENSE.

Package Sidebar

Install

npm i kodenami

Weekly Downloads

4

Version

2.0.2

License

MIT

Unpacked Size

24.5 kB

Total Files

11

Last publish

Collaborators

  • f_royen