Skip to content

Instantly share code, notes, and snippets.

@bholmberg
Created March 25, 2013 16:34
Show Gist options
  • Save bholmberg/5238495 to your computer and use it in GitHub Desktop.
Save bholmberg/5238495 to your computer and use it in GitHub Desktop.
AngularJS directive to cornify a web page when the "konami code" entered on the keyboard. I wrapped js I found on a blog into a DDO.
ngApp.directive("cornify", function () {
return {
link: function (scope, element, attrs) {
var konami_keys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
var konami_index = 0;
$(document).keydown(function(e){
if (e.keyCode === konami_keys[konami_index++]) {
if (konami_index === konami_keys.length) {
$(document).unbind('keydown', arguments.callee);
$.getScript('http://www.cornify.com/js/cornify.js',function(){
cornify_add();
$(document).keydown(cornify_add);
});
}
} else {
konami_index = 0;
}
});
}
};
});
@dos1
Copy link

dos1 commented Feb 19, 2014

I have modified this directive a bit to take custom callback to call when user enters the konami code :) https://github.com/dos1/angular-konami/blob/master/angular-konami.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment