Last active
August 29, 2015 13:56
-
-
Save omichelsen/8861701 to your computer and use it in GitHub Desktop.
JavaScript keySequence
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 keySequence(callback) { | |
var i = 0; | |
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; | |
$(document).keydown(function (event) { | |
if (konami[i] === event.which) { | |
i++; | |
if (konami.length === i) { | |
i = 0; | |
callback(); | |
} | |
} else { | |
i = +(konami[0] === event.which); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment