Skip to content

Instantly share code, notes, and snippets.

@master5o1

master5o1/konami.js

Last active Aug 29, 2015
Embed
What would you like to do?
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment