(function(jQuery){var hotkeys={};hotkeys.version='(beta)(0.0.6)';hotkeys.all={};hotkeys.newid=function(){return(Math.random()*0x10000000000|0).toString(32).substring(1)};hotkeys.special_keys={27:'esc',9:'tab',32:'space',13:'return',8:'backspace',145:'scroll',20:'capslock',144:'numlock',19:'pause',45:'insert',36:'home',46:'del',35:'end',33:'pageup',34:'pagedown',37:'left',38:'up',39:'right',40:'down',112:'f1',113:'f2',114:'f3',115:'f4',116:'f5',117:'f6',118:'f7',119:'f8',120:'f9',121:'f10',122:'f11',123:'f12'};hotkeys.shift_nums={"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"<",".":">","/":"?","\\":"|"};hotkeys.handler=function(event){var options=event.data;console.log(event);console.log(options);var element=event.currentTarget;element=(element.nodeType===3)?element.parentNode:element;if(options['disableInInput']){var target=jQuery(element);if(target.is("input")||target.is("textarea")){return}}var code=event.which,type=event.type,special=hotkeys.special_keys[code],character=!special&&String.fromCharCode(code).toLowerCase(),shift=event.shiftKey,ctrl=event.ctrlKey,alt=event.altKey||event.originalEvent.altKey,propagate=true,mapPoint=null;if(jQuery.browser.opera||jQuery.browser.safari||options.checkParent){while(!hotkeys.all[element.id]&&element.parentNode){console.log('checking the parent %s',element.parentNode);element=element.parentNode}}var key=(element===document&&element)||element.id;var cbMap=hotkeys.all[key].events[type].callbackMap;if(!shift&&!ctrl&&!alt){mapPoint=cbMap[special]||(character&&cbMap[character])}else{var modif='';if(alt)modif+='alt+';if(ctrl)modif+='ctrl+';if(shift)modif+='shift+';mapPoint=cbMap[modif+special];if(!mapPoint){if(character){mapPoint=cbMap[modif+character]||cbMap[modif+hotkeys.shift_nums[character]]}}}if(mapPoint){mapPoint.cb(event);if(!mapPoint.propagate){event.stopPropagation();event.preventDefault();return false}else{return true}}};hotkeys.add=function(combi,options,callback){if(jQuery.isFunction(options)){callback=options;options={}}var opt={},defaults={type:'keydown',propagate:false,disableInInput:false,target:document,checkParent:true};opt=jQuery.extend(opt,defaults,options||{});combi=combi.toLowerCase();if(!hotkeys.all[opt.target]){hotkeys.all[opt.target]={events:{}}}if(!hotkeys.all[opt.target].events[opt.type]){hotkeys.all[opt.target].events[opt.type]={callbackMap:{}}var target=opt.target===document&&opt.target||jQuery("#"+opt.target)[0];jQuery(target).bind(opt.type,opt,hotkeys.handler)}hotkeys.all[opt.target].events[opt.type].callbackMap[combi]={cb:callback,propagate:opt.propagate};return jQuery};hotkeys.bind=hotkeys.add;hotkeys.remove=function(exp,opt){opt=opt||{};target=opt.target||document;type=opt.type||'keydown';exp=exp.toLowerCase();delete hotkeys.all[target].events[type].callbackMap[exp]return jQuery};jQuery.hotkeys=hotkeys;return jQuery})(jQuery);