Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 6 days 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 (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T01:16:25.000Z (almost 2 years ago)
- Last Synced: 2024-11-05T13:24:03.343Z (about 2 months 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
![Build status](https://circleci.com/gh/sidp/konami-code.svg?style=shield&circle-token=60f119a2a516a777d99653c82df8c0cf7403cd52)
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.