Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/augbog/konami-komando
A simple JavaScript module that lets you pass a callback after a user has entered the Konami code.
https://github.com/augbog/konami-komando
callback event-listener games javascript konami konami-komando
Last synced: 10 days ago
JSON representation
A simple JavaScript module that lets you pass a callback after a user has entered the Konami code.
- Host: GitHub
- URL: https://github.com/augbog/konami-komando
- Owner: augbog
- License: mit
- Created: 2015-11-30T12:59:59.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-03T01:52:08.000Z (almost 9 years ago)
- Last Synced: 2024-10-17T06:30:47.730Z (21 days ago)
- Topics: callback, event-listener, games, javascript, konami, konami-komando
- Language: JavaScript
- Size: 3.91 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Konami Komando
A simple JavaScript module that lets you pass a callback after a user has entered the Konami code.
# Install
`npm install konami-komando --save-dev`
# Usage
```
require('konami-komando')({
once: true,
useCapture: true,
callback: function() {
// Do stuff here
}
});
```# Parameters
## once
Tells the code to only detect when a user has inputted the konami code once and then will no longer stop execution. If set to `false`, everytime the user inputs the konami code, the `callback` will be ran.If not specified, it will default to `true`.
## useCapture
Sets the priority of the event listener on `keydown`. This is important if you have your own event listeners on `keydown`. For more information on `useCapture`, check out this [StackOverflow answer about it](http://stackoverflow.com/questions/7398290/unable-to-understand-usecapture-attribute-in-addeventlistener) and also the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener).If not specified, it will default to `true`.
## callback
The action that should be ran after the konami code has been entered. If a function is not passed, it will throw an error.