Created
July 31, 2013 21:00
-
-
Save ljharb/6126127 to your computer and use it in GitHub Desktop.
Konami code implementation
This file contains 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 ($) { | |
var keys = [], code = '38,38,40,40,37,39,37,39,66,65'; | |
var konami = function (e) { | |
keys.push(e.which); | |
if (keys.length >= 11 && keys.slice(-11).toString() !== code) { | |
keys = []; | |
/* do your konami thing here */ | |
} else if (keys.length > 11) { | |
keys.length = 11; | |
} | |
}; | |
$(document).on('keydown', konami); | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment