function keypressfcn(hZoom,evd)
% Copyright 2005 The MathWorks, Inc.

consumekey = false;

if strcmp(hZoom.Debug,'on')
    disp('keypressfcn')
end

% Exit early if invalid conditions
if ~isstruct(evd) || ~isfield(evd,'Key') || ...
    isempty(evd.Key) || ~isfield(evd,'Character')
   return;
end

% Parse key press
zoomfactor = [];
switch evd.Key
    case 'uparrow'
        zoomfactor = 2;      
    case 'downarrow'
        zoomfactor = .9;    
    case 'alt'
        consumekey = true;
end

hFigure = get(hZoom,'FigureHandle');
if ishandle(hFigure)
    hAxes = get(hFigure,'CurrentAxes');
    if ~isempty(zoomfactor) && ishandle(hAxes)
        consumekey = true;
        applyzoomfactor(hZoom,hAxes,zoomfactor);
    end
end

if ~consumekey
    graph2dhelper('sendtocmdwin',hFigure,evd.Character);
end