
%%%%CALLBACK FUNCTION FOR KEYBOARD PRESS %%%%%
function myKeypress(~,evnt)
    global g;
    bUpdateText = 1;

    switch evnt.Key,
   	  case 'r'
          g.gamma = g.gamma + 0.05;
      case 'f'
          g.gamma = max(0,g.gamma - 0.05);
      case 'q'
          g.lagTime = g.lagTime + 0.05;
      case 'a'
          g.lagTime = max(0,g.lagTime - 0.05);
      case 'w'
          g.spdFactor(1) = g.spdFactor(1) + 0.5;
      case 's'
          g.spdFactor(1) = max(0,g.spdFactor(1) - 0.5);
      case {'e', 'pagedown'}
          g.spdFactor(2) = g.spdFactor(2) + 0.5;
      case {'d','pageup'}
          g.spdFactor(2) = g.spdFactor(2) - 0.5;
      case 'uparrow'
          g.arrowKey(2) = 1;          
      case 'downarrow'
          g.arrowKey(2) = -1;
      case 'rightarrow'
          g.arrowKey(1) = -1;
	  case 'leftarrow'
          g.arrowKey(1) = 1;
      otherwise
          bUpdateText = 0;
%             disp(['Currently no binding for: ' evnt.Key]);
    end
    
    if evnt.Key == 'p'
        g.bPause = ~g.bPause;
        PausString = 'PAUSED(HIT ANY KEY)   ';
        bUpdateText = 1;
    else
        g.bPause = 0;
        PausString = '';
    end

    if bUpdateText
        if strcmpi(g.kindOfMovie, 'synthetic')
            set(g.figH, 'Name',[PausString '[q,a]Lag:' num2str(g.lagTime,'%1.2f') ',  [w,s]Speed:' num2str(g.spdFactor(1),'%2.1f')  ',  [e,d]Rotation:' num2str(g.spdFactor(2),'%2.1f') ',  [r,f]Gamma:'  num2str(g.gamma,'%2.2f') ]);
        else 
            set(g.figH, 'Name',[PausString '[q,a]Lag:' num2str(g.lagTime,'%1.2f') ',  [r,f]Gamma:'  num2str(g.gamma,'%2.2f') ]);
        end
    end
  
    
    
    
    
    
    
    
    
    
    
    