Created
May 24, 2012 03:57
-
-
Save ahomu/2779343 to your computer and use it in GitHub Desktop.
コナミコマンド
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
$(document).bind('keydown', detectKonamiCommand); | |
var konamiTimer, | |
konamiLog = [], | |
keyMap = { | |
37: '←', | |
38: '↑', | |
39: '→', | |
40: '↓', | |
65: 'A', | |
66: 'B' | |
}; | |
function detectKonamiCommand(e) { | |
clearTimeout(konamiTimer); | |
konamiLog.push(keyMap[e.keyCode]); | |
if (konamiLog.join('').indexOf('↑↑↓↓←→←→BA') !== -1) { | |
console.log('konami!!!!!!!!!!!!!'); | |
konamiLog = []; | |
} | |
konamiTimer = setTimeout(function() { | |
console.log('clear'); | |
konamiLog = []; | |
}, 800); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment