├── .gitignore ├── README.md ├── bower.json ├── changelog.md ├── demo ├── demo.html └── demo.js └── src ├── jquery.konami.js ├── jquery.konami.min.js ├── vanilla.konami.js └── vanilla.konami.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | bower_components -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Konami Code For jQuery 2 | By [Tom McFarlin](https://tommcfarlin.com). Last Updated 4 December 2015. 3 | 4 | ## About 5 | 6 | Using the Konami code, easily configure and Easter Egg for your page or any element on the page. 7 | 8 | ## Parameters 9 | 10 | * `code` Personalized code. 11 | * `cheat` The callback function to fire once the cheat code has been entered. 12 | * `eventName` jQuery event name for default callback 13 | * `eventProperties` event property override for default callback 14 | 15 | ## Installation 16 | ```sh 17 | bower install konami-code 18 | ``` 19 | 20 | ## Instructions 21 | 22 | Include the plugin in the header of your page: 23 | 24 | ```html 25 | ` 26 | 27 | ``` 28 | 29 | ### With callback 30 | 31 | Apply the plugin to a selector to capture keypresses: 32 | 33 | ```js 34 | $( window ).konami(); 35 | ``` 36 | 37 | ```js 38 | $( '.konami-sensitive' ).konami(); 39 | ``` 40 | 41 | Specify a callback to fire once the code has been entered: 42 | 43 | ```js 44 | $( window ).konami({ 45 | cheat: function() { 46 | alert( 'Cheat code activated!' ); 47 | } 48 | }); 49 | ``` 50 | 51 | ### Using jQuery events 52 | 53 | Catch the konami code with a jQuery event handler: 54 | 55 | ```js 56 | $( window ).konami(); 57 | $( window ).on('konami', function() { 58 | alert( 'Cheat code activated!' ); 59 | }) 60 | ``` 61 | 62 | Add extra data to the jQuery event callback: 63 | 64 | ```js 65 | $( window ).konami( { message: 'special message' } ); 66 | $( window ).on('konami', function(evt, extraParam) { 67 | alert( 'Cheat code activated: ' + extraParam.message + '!' ); 68 | }) 69 | ``` 70 | 71 | Use event names: 72 | 73 | ```js 74 | $('.type1').konami( { eventName: 'konami.on.type1' } ); 75 | $('.type2').konami( { eventName: 'konami.on.type2' } ); 76 | $( window ).on('konami.on.type2', function(evt, extraParam) { 77 | alert( 'Cheat code activated on a type2 element' ); 78 | }) 79 | ``` 80 | 81 | ### Personallizing the code 82 | 83 | You can personalize the code too, just entering a array with ASCII codes keys in code param 84 | 85 | ```js 86 | $( window ).konami({ 87 | code : [38,38,40,40,37,39,37,39], // up up down down left right left right 88 | cheat: function() { 89 | alert( 'Cheat code activated!' ); 90 | } 91 | }); 92 | ``` 93 | 94 | 95 | ## Contact 96 | 97 | * Web: [Tom McFarlin](https://tommcfarlin.com) 98 | * Twitter: [@tommcfarlin](https://twitter.com/tommcfarlin/) 99 | 100 | ## License 101 | 102 | [MIT license](http://www.opensource.org/licenses/mit-license.php) 103 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "konami-code", 3 | "version": "1.3.3", 4 | "homepage": "https://github.com/tommcfarlin/konami-code", 5 | "authors": [ 6 | { 7 | "name": "Tom McFarlin", 8 | "email": "tom@tommcfarlin.com", 9 | "homepage": "https://tommcfarlin.com" 10 | } 11 | ], 12 | "description": "Using the Konami code, easily configure and Easter Egg for your page or any element on the page.", 13 | "main": "./src/jquery.konami.min.js", 14 | "keywords": [ 15 | "konami", "jquery", "js" 16 | ], 17 | "license": "MIT", 18 | "ignore": [ 19 | "**/.*", 20 | "node_modules", 21 | "bower_components", 22 | "test", 23 | "tests" 24 | ], 25 | "dependencies": { 26 | "jquery": ">= 1.10.2" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /changelog.md: -------------------------------------------------------------------------------- 1 | _1.3.3_ (4 December 2015) 2 | 3 | * Updating README 4 | * Tagging for Bower support 5 | 6 | _1.3.1_ 7 | 8 | * jQuery events supported 9 | 10 | _1.3.0 (7 March 2014)_ 11 | 12 | * Minor updates to the coding conventions and docblocks 13 | * Tagging for registration in the Bower repository 14 | 15 | _1.2.2 (6 March 2014)_ 16 | 17 | * Added support for bower (bower.json) 18 | 19 | _1.2.1 (23 October 2013)_ 20 | 21 | * Added option to customize the code 22 | 23 | _1.2.0 (11 October 2013)_ 24 | 25 | * Additional, minor refactoring for strong JSLint 26 | * Removing extranneous whitespace 27 | * Moving the plugin to a `src` directory 28 | * Updated the demo to the latest version of jQuery 29 | * Updated the code for jQuery 30 | * Updated authorship information 31 | * Updated the version number in the plugin 32 | * Updated the README and the changelog 33 | 34 | _1.1.0 (10, October, 2013)_ 35 | 36 | * Refactoring some of the code up to JSLint standards 37 | * Updating the changelog to markdown 38 | * Updating the README to markdown 39 | * Removed the MIT License and included it in the README 40 | 41 | _1.0.0 4 March 2011_ 42 | 43 | * Initial release 44 | * 3/14/2011 -------------------------------------------------------------------------------- /demo/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |