Created
December 8, 2010 19:23
-
-
Save joemccann/733758 to your computer and use it in GitHub Desktop.
Konami code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($) { | |
| $.fn.konami = function(callback, code) { | |
| if (code == undefined) code = "38,38,40,40,37,39,37,39,66,65"; | |
| return this.each(function() { | |
| var kkeys = []; | |
| $(this).keydown(function(e) { | |
| kkeys.push(e.keyCode); | |
| if (kkeys.toString().indexOf(code) >= 0) { | |
| $(this).unbind('keydown', arguments.callee); | |
| callback(e); | |
| } | |
| }, true); | |
| }); | |
| } | |
| })(jQuery); | |
| $(document).ready(function(){ | |
| $(window).konami(function(){ | |
| alert('Konami Code Activated'); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment