Skip to content

Instantly share code, notes, and snippets.

@paceaux
Created May 18, 2012 23:03
Show Gist options
  • Save paceaux/2728020 to your computer and use it in GitHub Desktop.
Save paceaux/2728020 to your computer and use it in GitHub Desktop.
Konami Contenteditable plugin
(function($){
$.fn.kedit = function() {
var konami_keys = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
var konami_index = 0;
this.keydown(function(e){
if(e.keyCode === konami_keys[konami_index++]){
if(konami_index === konami_keys.length){
$(document).unbind('keydown', arguments.callee);
$('article, aside, header, footer, p, li, span').dblclick(function(e){
var $this = $(this);
$this.attr("contenteditable", true).css({'outline':'2px dotted #333'});
$this.focusout(function(e){
$this.attr("contenteditable", false).css({'outline':'none'});
});
});
}
}else{
konami_index = 0;
}
});
};
})( jQuery );
$(document).kedit();​
@paceaux
Copy link
Author

paceaux commented May 18, 2012

This is a very basic jquery plugin that uses the Konami code to "unlock" your ability to edit any content on the page. After the Konami code, you can double click most elements to edit them. The Konami code, BTW, is up up down down left right left right b a

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