This is a small Javascript library to call functions when the user enters the Konami Code.
↑ ↑ ↓ ↓ ← → ← → B A
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();
});
This library supports all modern browsers, including Internet Explorer 9 and better.