< 140 bytes Konami Code
-
-
Save padawin/10396730 to your computer and use it in GitHub Desktop.
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
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(a,c){ // a == the secret action to execute | |
// c = a placeholder to log the index of | |
// the next key which is expected | |
// in the code | |
document.onkeyup=function(e){ // | |
c=( // Update the value of c depending on the | |
// typed key | |
( | |
e||self.event // Browser compat | |
).keyCode-37 // Substraction to have as many | |
// lower-than-ten keys as possible | |
)==[1,1,3,3,0,2,0,2,29,28][c] // If the typed key is the current key | |
// in the code | |
&& | |
( // c will be incremented, but | |
c==9 // if, when incremented, c == 9, the | |
// code is complete, so | |
&&a() // execute the action | |
||c+1 // overwise, increment c | |
) | |
|| | |
0; // else, if the key is not the next in | |
// the code, reset the cursor | |
} | |
} |
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(a,c){document.onkeyup=function(e){c=((e||self.event).keyCode-37)==[1,1,3,3,0,2,0,2,29,28][c]&&(c==9&&a()||c+1)||0;}} |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
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
{ | |
"name": "KonamiCode", | |
"description": "140bytes implementation of the Konami Code", | |
"keywords": [ | |
"Konami", | |
"Code", | |
"Konami Code", | |
"Easter", | |
"Egg", | |
"Easter egg" | |
] | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript"> | |
var action=function(){ | |
console.log("konami"); | |
}; | |
(function(a,c){document.onkeyup=function(e){c=((e||self.event).keyCode-37)==[1,1,3,3,0,2,0,2,29,28][c]&&(c==9&&a()||c+1)||0;}})(action); | |
</script> | |
</head> | |
<body></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's been done before, and even smaller: https://gist.github.com/tsaniel/1188477