jQuery Plugin To Enable Custom Cheat Codes On Webpage - cheat-code.js

File Size: 11.4 KB
Views Total: 490
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Enable Custom Cheat Codes On Webpage - cheat-code.js

cheat-code.js is a very small jQuery plugin that adds custom keypress cheat codes (e.g. Konami Cheat Code) to your webpage. The plugin allows to trigger an event callback after the users type the correct key sequence. Can be present as an Easter egg on the webpage.

How to use it:

1. Include jQuery library and the jQuery cheat-code.js on the bottom of the webpage.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="js/jquery.cheat-code.js"></script>

2. Call the function and override the default Konami cheat code.

$(document).cheatCode({

  // konami code
  code: '38384040373937396665' // key codes

});

3. Specify the time in milliseconds allowed between sequential key presses before the input is reset.

$(document).cheatCode({

  time: 500,

});

4. Execute a custom callback when the cheat code is typed correctly.

$(document).cheatCode({

  callback: function() {
    // do something
  }

});

Change log:

v1.4.1 (2017-08-29)

  • Updated versioning to semantic style
  • The plugin now runs in strict mode

2016-09-03

  • Added code generator; code option now accepts both strings and numbers representing a key code series

This awesome jQuery plugin is developed by kevinberonilla. For more Advanced Usages, please check the demo page or visit the official website.