Skip to content

Instantly share code, notes, and snippets.

@g-i-o-
Created December 10, 2014 18:15
Show Gist options
  • Save g-i-o-/875dd9d60b8320e7dcc7 to your computer and use it in GitHub Desktop.
Save g-i-o-/875dd9d60b8320e7dcc7 to your computer and use it in GitHub Desktop.
angular module for the konami code
angular.module('angular-konami', [])
.run(function($rootScope){
var code = [38,38,40,40,37,39,37,39,65,66,13];
var stack = [];
$(document).keydown(function(evt){
console.log(evt.which);
stack.push(evt.which);
if(stack.length > code.length){
stack.shift();
} else if(stack.length == code.length){
if(stack.filter(function(k, i){
return k != code[i];
}).length === 0){
$rootScope.$broadcast('konami-code');
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment