konami-code-js
Advanced tools
Comparing version 0.5.0 to 0.7.0
{ | ||
"name": "konami-code-js", | ||
"version": "0.5.0", | ||
"version": "0.7.0", | ||
"description": "Fire a JavaScript Event when you enter the « Up Up Bottom Bottom Left Right Left Right B A » Konami Code Sequence.", | ||
@@ -27,3 +27,3 @@ "main": "src/konami-code.js", | ||
"author": "Bruno Lesieur", | ||
"license": "GPL-2.0", | ||
"license": "GPL-3.0", | ||
"bugs": { | ||
@@ -30,0 +30,0 @@ "url": "https://github.com/Haeresis/konami-code-js/issues" |
# KonamiCodeJS # | ||
Fire a JavaScript Event when you enter the « Up Up Bottom Bottom Left Right Left Right B A » Konami Code Sequence. | ||
Fire a JavaScript Event when you enter the « Up Up Bottom Bottom Left Right Left Right B A » Konami Code Sequence with your keyboard. That work also when you do the following touch gesture « Up Up Bottom Bottom Left Right Left Right Tap Tap » with your finger. | ||
----- | ||
**Vous êtes français ? Le README [derrière ce lien](http://blog.lesieur.name/des-easter-eggs-avec-konami-code-js/) vous sera peut-être plus agréable.** | ||
## Basic Usage ## | ||
@@ -50,3 +54,3 @@ | ||
**Version**: 0.5.0 | ||
**Version**: 0.7.0 | ||
@@ -87,2 +91,18 @@ **Author:** [Bruno Lesieur](http://www.lesieur.name/) | ||
**Returns**: <code>[KonamiCode](#KonamiCode)</code> - Current instance of KonamiCode | ||
<a name="KonamiCode+enableKeyboardKeys"></a> | ||
### konamiCode.enableKeyboardKeys() ⇒ <code>[KonamiCode](#KonamiCode)</code> | ||
Active the listening of Konami Code Sequence for Keyboard Keys. | ||
**Kind**: instance method of <code>[KonamiCode](#KonamiCode)</code> | ||
**Returns**: <code>[KonamiCode](#KonamiCode)</code> - Current instance of KonamiCode | ||
<a name="KonamiCode+enableTouchGesture"></a> | ||
### konamiCode.enableTouchGesture() ⇒ <code>[KonamiCode](#KonamiCode)</code> | ||
Active the listening of Konami Code Sequence for Touch Gesture. | ||
**Kind**: instance method of <code>[KonamiCode](#KonamiCode)</code> | ||
**Returns**: <code>[KonamiCode](#KonamiCode)</code> - Current instance of KonamiCode | ||
<a name="KonamiCode+disable"></a> | ||
@@ -96,4 +116,12 @@ | ||
**Returns**: <code>[KonamiCode](#KonamiCode)</code> - Current instance of KonamiCode | ||
<a name="KonamiCode+setListener"></a> | ||
<a name="KonamiCode+disabledKeyboardKeys"></a> | ||
### konamiCode.disabledKeyboardKeys() ⇒ <code>[KonamiCode](#KonamiCode)</code> | ||
Unactive the listening of Konami Code Sequence for Keyboard Keys. | ||
**Kind**: instance method of <code>[KonamiCode](#KonamiCode)</code> | ||
**Returns**: <code>[KonamiCode](#KonamiCode)</code> - Current instance of KonamiCode | ||
<a name="KonamiCode+disabledTouchGesture"></a> | ||
### konamiCode.setListener(listener) ⇒ <code>[KonamiCode](#KonamiCode)</code> | ||
@@ -163,3 +191,3 @@ Change the listener. The old listener will no longer work. Note: change the listener enable this instance if it is previously `disable()`. | ||
All public functions return the current instance of KonamiCode. That allows you to use instance like this. | ||
All API instanciated methods return the current instance of `KonamiCode` Object. That allows you to use instance like this. | ||
@@ -202,2 +230,8 @@ ```js | ||
### By Direct Download ### | ||
- [https://github.com/Haeresis/konami-code-js/blob/master/src/konami-code.js](https://github.com/Haeresis/konami-code-js/blob/master/src/konami-code.js) | ||
### From NPM ### | ||
@@ -204,0 +238,0 @@ |
/* global define, module */ | ||
/** | ||
* Create Konami Code Sequence recognition « Up Up Bottom Bottom Left Right Left Right B A » on specific HTMLElement or on global HTMLDocument. | ||
* Create Konami Code Sequence recognition « Up Up Bottom Bottom Left Right Left Right B A » on specific HTMLElement or on global HTMLDocument. Usage of finger is also possible with « Up Up Bottom Bottom Left Right Left Right Tap Tap ». | ||
* @class KonamiCode | ||
* @version 0.5.0 | ||
* @version 0.7.0 | ||
* @author {@link http://www.lesieur.name/|Bruno Lesieur} | ||
@@ -66,4 +66,5 @@ * @param {Object|Function} [options] - Container for all options. If type of `options` is Function, it is executed after Konami Code Sequence has been recognize. | ||
publics.enable = function () { | ||
privates.listenCodeSequence(); | ||
privates.debug && privates.debug("Listener enabled."); | ||
privates.listenCodeCharSequence(); | ||
privates.listenCodeGestureSequence(); | ||
privates.debug && privates.debug("Listener enabled for all."); | ||
@@ -74,2 +75,28 @@ return publics; | ||
/** | ||
* Active the listening of Konami Code Sequence for Keyboard Keys. | ||
* @function enableKeyboardKeys | ||
* @memberOf KonamiCode# | ||
* @return {KonamiCode} Current instance of KonamiCode | ||
*/ | ||
publics.enableKeyboardKeys = function () { | ||
privates.listenCodeCharSequence(); | ||
privates.debug && privates.debug("Listener enabled for Keyboard Keys."); | ||
return publics; | ||
}; | ||
/** | ||
* Active the listening of Konami Code Sequence for Touch Gesture. | ||
* @function enableTouchGesture | ||
* @memberOf KonamiCode# | ||
* @return {KonamiCode} Current instance of KonamiCode | ||
*/ | ||
publics.enableTouchGesture = function () { | ||
privates.listenCodeGestureSequence(); | ||
privates.debug && privates.debug("Listener enabled for Touch Gesture."); | ||
return publics; | ||
}; | ||
/** | ||
* Unactive the listening of Konami Code Sequence. | ||
@@ -81,4 +108,5 @@ * @function disable | ||
publics.disable = function () { | ||
privates.stopCodeSequence(); | ||
privates.debug && privates.debug("Listener disabled."); | ||
privates.stopCodeCharSequence(); | ||
privates.stopCodeGestureSequence(); | ||
privates.debug && privates.debug("Listener disabled for all."); | ||
@@ -89,3 +117,29 @@ return publics; | ||
/** | ||
* Change the listener. The old listener will no longer work. Note: change the listener enable this instance if it is previously `disable()`. | ||
* Unactive the listening of Konami Code Sequence for Keyboard Keys. | ||
* @function disabledKeyboardKeys | ||
* @memberOf KonamiCode# | ||
* @return {KonamiCode} Current instance of KonamiCode | ||
*/ | ||
publics.disableKeyboardKeys = function () { | ||
privates.stopCodeCharSequence(); | ||
privates.debug && privates.debug("Listener disabled for Keyboard Keys."); | ||
return publics; | ||
}; | ||
/** | ||
* Unactive the listening of Konami Code Sequence for Touch Gesture. | ||
* @function disabledTouchGesture | ||
* @memberOf KonamiCode# | ||
* @return {KonamiCode} Current instance of KonamiCode | ||
*/ | ||
publics.disableTouchGesture = function () { | ||
privates.stopCodeGestureSequence(); | ||
privates.debug && privates.debug("Listener disabled for Touch Gesture."); | ||
return publics; | ||
}; | ||
/** | ||
* Change the listener. The old listener will no longer work. Note: change the listener enable this instance if it is previously disabled. | ||
* @function setListener | ||
@@ -97,5 +151,7 @@ * @param {Node} listener - You can pass some HTMLElement like `<input>` (HTMLInputElement) to only recognize Konami Code Sequence from this element. | ||
publics.setListener = function (listener) { | ||
privates.stopCodeSequence(); | ||
privates.stopCodeCharSequence(); | ||
privates.stopCodeGestureSequence(); | ||
privates.listener = listener || document; | ||
privates.listenCodeSequence(); | ||
privates.listenCodeCharSequence(); | ||
privates.listenCodeGestureSequence(); | ||
privates.debug && privates.debug("Listener changed.", listener); | ||
@@ -171,4 +227,7 @@ | ||
privates.stopCodeSequence = function () { | ||
privates.stopCodeCharSequence = function () { | ||
privates.listener.removeEventListener("keydown", privates.codeSequenceEventKeyDown); | ||
}; | ||
privates.stopCodeGestureSequence = function () { | ||
privates.listener.removeEventListener("touchstart", privates.codeSequenceEventTouchStart); | ||
@@ -179,6 +238,10 @@ privates.listener.removeEventListener("touchmove", privates.codeSequenceEventTouchMove); | ||
privates.listenCodeSequence = function () { | ||
privates.listenCodeCharSequence = function () { | ||
privates.stopCodeCharSequence(); | ||
privates.listener.addEventListener("keydown", privates.codeSequenceEventKeyDown); | ||
}; | ||
privates.listenCodeGestureSequence = function () { | ||
privates.originalCodeGesture = privates.konamiCodeGesture; | ||
privates.stopCodeSequence(); | ||
privates.listener.addEventListener("keydown", privates.codeSequenceEventKeyDown); | ||
privates.stopCodeGestureSequence(); | ||
privates.listener.addEventListener("touchstart", privates.codeSequenceEventTouchStart); | ||
@@ -245,3 +308,4 @@ privates.listener.addEventListener("touchmove", privates.codeSequenceEventTouchMove); | ||
privates.listenCodeSequence(); | ||
privates.listenCodeCharSequence(); | ||
privates.listenCodeGestureSequence(); | ||
}; | ||
@@ -248,0 +312,0 @@ |
Sorry, the diff of this file is not supported yet
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
69471
263
283