-
-
Save sameerkat/64137803a09dc8ad58b2 to your computer and use it in GitHub Desktop.
Konami Code in Javascript
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 konami(cb) { | |
var code = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; | |
var pos = 0; | |
document.onkeydown = function(e) { | |
if(code[pos] === e.which) { | |
if(++pos >= code.length) { | |
if(typeof cb == String.fromCharCode(102,117,110,99,116,105,111,110)) | |
cb(); | |
pos = 0; | |
} | |
} else if(e.which !== 38) { | |
pos = 0; | |
} | |
} | |
} | |
/* | |
konami(function() { | |
document.location = String.fromCharCode(104,116,116,112,58,47,47,119,119,119,46,121,111,117,116,117,98,101,46,99,111,109,47,119,97,116,99,104,63,118,61,100,81,119,52,119,57,87,103,88,99,81) | |
}) | |
*/ | |
/* | |
function a(a){var b=[38,38,40,40,37,39,37,39,66,65],c=0;document.onkeydown=function(d){b[c]===d.which?++c>=b.length&&(typeof a==String.fromCharCode(102,117,110,99,116,105,111,110)&&a(),c=0):d.which!==38&&(c=0)}}a(function(){document.location=String.fromCharCode(104,116,116,112,58,47,47,119,119,119,46,121,111,117,116,117,98,101,46,99,111,109,47,119,97,116,99,104,63,118,61,100,81,119,52,119,57,87,103,88,99,81)}); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment