Author: | mikeflynn |
---|---|
Views Total: | 822 views |
Official Page: | Go to website |
Last Update: | May 16, 2019 |
License: | MIT |
Preview:

Description:
egg.js is a small (1.5kb) vanilla JavaScript library that adds easter eggs triggered by keyboard sequences to your webpage.
For example, you can trigger a custom function when the users type the famous Konami Code (up, up, down, down, left, right, left, right, B, A) on the webpage.
How to use it:
Download and put the egg.js library right before the closing body tag.
<script src="egg.min.js"></script>
Initialize the egg.js library.
var egg = new Egg();
Define a sequence of keyboard keys and specify a function to trigger as follows:
egg.addCode("up,up,down,down", function() { alert('done') }).listen();
Trigger a function after any egg code is triggered.
egg.addCode("up,up,down,down", function() { alert('done') }).addHook(function(){ console.log("Hook called for: " + this.activeEgg.keys); console.log(this.activeEgg.metadata); }).listen();