function addkbcallback(fig,handler)
% addkbcallback - Add keypress handler to figure or remove all handlers

	if nargin>1,
		cb=get(fig,'KeypressFcn');
		if isempty(cb)
			set(fig,'KeypressFcn',{@kpcb,{handler}});
		else
			set(fig,'KeypressFcn',{cb{1},[cb{2},{handler}]});
		end
	else
		set(fig,'KeypressFcn',[]);
	end
end

function kpcb(a,b,handlers), 
	for i=1:length(handlers), h=handlers{i}; h(b); end; 
end

