Add Konami Code (Or Custom Cheat Code) To Webpage- jQuery jKonamiCode
File Size: | 39.9 KB |
---|---|
Views Total: | 1369 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
Yet another keypress cheat code plugin that adds the familiar Konami Code or any pre-defined key sequence to your webpage.
You're able to assign the Konami Code to any actions you prefer (for example: Easter egg on the webpage).
How to use it:
1. Include the JavaScript jKonamiCode.js
after loading jQuery JavaScript library.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script> <script src="jKonamiCode.js"></script>
2. Execute a function when the user types the correct Konami Code (Up Up Down Down Left Right Left Right B A).
$(function(){ $(window).jKonamicode(function(){ alert("Hello World!"); }); });
3. To create a custom cheat code, define a sequence of keystrokes using JavaScript Keycodes.
$(function(){ $(window).jKonamicode({ { code:[38,38,40,40,37,39,37,39,66,65], }, function(){ alert("Hello World!"); } ); });
4. Execute a function each time you press the right key.
$(function(){ $(window).jKonamicode({ { code:[38,38,40,40,37,39,37,39,66,65], onRightKey:function(e){ alert("You entered "+e+" right keys."); } }, function(){ alert("Hello World!"); } ); });
This awesome jQuery plugin is developed by Leoche. For more Advanced Usages, please check the demo page or visit the official website.