$.fn.extend({
 enter:function (callback) {
  return $(this).keydown(function(e){
   if (e.keyCode == 13) {
    e.preventDefault();
    callback($(this));
   }
  });
 },
 escape: function (callback) {
  return $(this).keydown(function(e){
   if (e.keyCode == 27) {
    e.preventDefault();
    callback($(this));
   }
  });
 },
 myselect: function () {
  return $(this).mouseup(function(e){
   e.preventDefault();
  }).focus(function(){
   $(this).select();
  });
 },
 mytoggle: function (selector) {
  ($('#'+(id = selector.replace(/[^a-z0-9]/g,'_'))).size() > 0) ? $('#'+id).remove() : $('<style type="text/css" id="'+id+'">'+selector+' { display: none !important; }</style>').appendTo('head');
 },
 mystyle: function (selector,style) {
  ($('#'+(id = (selector+style).replace(/[^a-z0-9]/g,'_'))).size() > 0) ? $('#'+id).remove() : $('<style type="text/css" id="'+id+'">'+selector+' { '+style+' }</style>').appendTo('head');
 }
});

$(function(){
 $('#test_enter').val('test on me').myselect().enter(function(o){o.val(function(i,v){$(this).next().html('<b>enter</b> with value: [<i>'+v+'</i>]'); return '';});}).escape(function(o){o.val(function(i,v){$(this).next().html('<b>escape</b> with value: [<i>'+v+'</i>]'); return '';})});
 $('#test_select1').focus(function(){$(this).select()});
 $('#test_select2').myselect();
});
