1.0.1 • Published 5 years ago

@sidp/konami-code v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

konami-code

Build status

This is a small Javascript library to call functions when the user enters the Konami Code.

↑ ↑ ↓ ↓ ← → ← → B A

Usage

Install the package from npm:

npm install @sidp/konami-code

Import the package into your project. Add a function by passing it as an argument to the konamiCode function.

import konamiCode from '@sidp/konami-code';

konamiCode(() => {
  /* do stuff */
});

If you want to remove the listener, call the remove() function on the returned object, or on this in the callback function:

const kc = konamiCode(() => {
  /* do stuff */
});
kc.remove();

// - or -

konamiCode(function() {
  /* do stuff */
  this.remove();
});

Browser support

This library supports all modern browsers, including Internet Explorer 9 and better.