function clsKeyboard(){
  this.keys = new Array;
  this.events=new Array;
  
  this.addEvent=function(keys,func){
      
      this.events[this.events.length]={ keys: keys, func : func};
  };
  
  this.event=function(){
    var event;
    var key;
    
    for( var i in this.events){
      event=this.events[i];
      if(this.combo(event.keys))event.func();
    }
  };
  
  this.combo=function(keys){
    for( var i in keys ){
        id=keys[i];
        if(!this.keys[id])return false;
    }
    return true;
  };
  
  
  this.showDown=function(){
   var str="";
    for (var i in this.keys){
      if(this.keys[i]){
        str+="+"+i;
      }
    }
    alert(str);
  };
  
  this.up=function(key){
    this.keys[key]=false;
    
  };
  this.down=function(key){
    this.keys[key]=true;
    this.event();
  };
 
}
var keyboard=new clsKeyboard;
  
$(document).keyup(function (e) { 
    keyboard.up(e.which);
});
$(document).keydown(function (e) {
	//alert(e.which);
    keyboard.down(e.which);
}); 


function catchEnter(e,fn,data){
	if (e.which == 13)fn(data);
}