konami.js
2015-03-26 03:29
konami(function(){
console.log('KONAMI!!!');
});
function konami(fn, match) {
var konamiCode = '3838404037393739666513';
var sequence = '';
match = match || konamiCode;
window.addEventListener('keyup', function(event){
sequence += event.keyCode;
if (match === sequence) {
fn();
}
if (match.indexOf(sequence) === -1) {
sequence = '';
}
}, false);
}