Easily hide your easter eggs in the browser!
npm install easter-egg``npm install easter-egg --save`
``
`javascript`
cheet('e a s t e r', function () { alert('Hidden easter Egg!'); });
`javascript`
cheet('↑ ↑ ↓ ↓ ←', function () {
alert('You found the easter egg!');
});
`javascript
cheet('s e q u e n c e', {
next: function (str, key, num, seq) {
console.log('key pressed: ' + key);
console.log('progress: ' + num / seq.length);
console.log('seq: ' + seq.join(' '));
},
fail: function () {
console.log('sequence failed');
},
done: function () {
console.log('Hello Easter Egg!');
}
});
`
`javascript`
cheet('o n c e', function () {
console.log('This will only fire once.');
cheet.disable('o n c e');
});
`javascript
var sequences = {
sequence: 'up down left right',
circle: 'left up right down'
};
cheet(sequences.sequence);
cheet(sequences.circle);
cheet.done(function (seq) {
if (seq === sequences.sequence) {
console.log('sequence!');
} else {
console.log('circle!');
}
});
`$3
#### cheet(sequence, done | {next,fail,done})
Map a sequence of keypresses to a callback. This can be called multiple times.
>
> sequence (String)
> > A string representation of a sequence of key names.
> >
> > Each keyname must be separated by a single space.
>
>
> done(str, seq) (callback)
> > A callback to execute each time the sequence is correctly pressed.
> >
> > Arguments:
> > * str - The string representation of the sequence that completed.seq
> > * - An array of key names representing the sequence that completed.fail(str, seq)
>
>
> (callback)str
> > A callback to execute each time a sequence's progress is broken.
> >
> > Arguments:
> > * - The string representation of the sequence that failed.seq
> > * - An array of key names representing the sequence that was pressed.next(str, key, num, seq)
>
>
> (callback)str
> > A callback to execute each time a correct key in the sequence is pressed in order.
> >
> > Arguments:
> > * - The string representation of the sequence that is in progress.key
> > * - The name of the key that was just pressed.num
> > * - A number representing the current progress of the sequence. (starts at 0)seq
> > * - An array of key names representing the sequence that is in progress.
#### cheet.done(callback)
Set a global callback that executes whenever any mapped sequence is completed successfully.
>
> callback(str, seq) (callback)
> > A callback to execute each time any sequence is correctly pressed.
> >
> > Arguments:
> > * str - The string representation of the sequence that completed.seq
> > * - An array of key names representing the sequence that completed.
#### cheet.next(callback)
Set a global callback that executes whenever any mapped sequence progresses.
>
> callback(str, key, num, seq) (callback)
> > A callback to execute each time a correct key in any sequence is pressed in order.
> >
> > Arguments:
> > * str - The string representation of the sequence that is in progress.key
> > * - The name of the key that was just pressed.num
> > * - A number representing the current progress of the sequence. (starts at 0)seq
> > * - An array of key names representing the sequence that is in progress.
#### cheet.fail(callback)
Set a global callback that executes whenever any in-progress sequence is broken.
>
> callback(str, seq) (callback)
> > A callback to execute each time any sequence's progress is broken.
> >
> > Arguments:
> > * str - The string representation of the sequence that failed.seq
> > * - An array of key names representing the sequence that was pressed.
Disable a previously-mapped sequence.
>
> sequence (String)
> > The same string you used to map the callback when using cheet(seq, ...).
Resets a sequence that may or may not be in progress.
This will not cause fail callbacks to fire, but will effectively
cancel the sequence.
>
> sequence (String)
> > The same string you used to map the callback when using cheet(seq, ...).
NOTE: Key names are case-sensitive
#### Directionals
* left | L | ←up
* | U | ↑right
* | R | →down
* | D | ↓
#### Alphanumeric
* 0-9 (main number keys)a
* -z
#### Misc
* backspacetab
* enter
* | returnshift
* | ⇧control
* | ctrl | ⌃alt
* | option | ⌥command
* | ⌘pause
* capslock
* esc
* space
* pageup
* pagedown
* end
* home
* insert
* delete
* equal
* | =comma
* | ,minus
* | -period
* | .
#### Keypad
* kp_0-kp_9kp_multiply
* kp_plus
* kp_minus
* kp_decimal
* kp_divide`
*