https://github.com/sidp/konami-code
Small Javascript library to call functions when the user enters the Konami Code.
https://github.com/sidp/konami-code
Last synced: about 1 year ago
JSON representation
Small Javascript library to call functions when the user enters the Konami Code.
- Host: GitHub
- URL: https://github.com/sidp/konami-code
- Owner: sidp
- License: mit
- Created: 2015-06-03T16:45:42.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T01:16:25.000Z (over 3 years ago)
- Last Synced: 2025-02-15T00:45:39.598Z (over 1 year ago)
- Language: TypeScript
- Size: 272 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# konami-code

This is a small Javascript library to call functions when the user enters the Konami Code.
> ↑ ↑ ↓ ↓ ← → ← → B A
## Usage
Install the package from npm:
```sh
npm install @sidp/konami-code
```
Import the package into your project. Add a function by passing it as an argument to the konamiCode function.
```js
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:
```js
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.