Как-нибудь так... На коленке сочинилось...
Код | var hotStore=[];
function newHotKey(option,func){ if (func) { var x={}; x.flags=option.flags||0; x.code=option.code||0; x.func=func; hotStore.pop(x); } else // тут надо найти по flags, code и удалить ранее вставленный элемент }
function kListener(event){ event = event || window.event; var ccode = event.keyCode || event.which || null, flags= (event.ctrlKey?1:0)+(event.shiftKey?2:0), hl= hotStore.length; while(hl--){ if(hotStore[hl].flags==flags && hotStore[hl].code==ccode) hotStore[hl].func(); } }
var key_combination={ CtrlForward:{flags:1,code: 0x27}, CtrlBack:{flags:1,code: 0x25}, }
function kBind(act,func){ if(key_combination[act]){ return newHotKey({key_combination[act]},func) } return false; }
function kUBind(act){ kBind(act); }
|
|