title: Delphi How to Use UpArrow DownArrow to navigate
body: <p>I have a form with a TDBGrid and TClientDatabase.</p>
  
  <p>I want to allow using the UpArrow or DownArrow to navigate in the database no matter which control has focus.</p>
  
  <p>I set the Form.KeyPreview := true</p>
  
  <p>This is the Form.OnKeyPress</p>
  
  <pre><code>procedure TfrmMain.FormKeyPress(Sender: TObject; var Key: Char); 
  var Direction : Integer; 
  begin    
     Direction := -1;    
     if Key = VK_UP then Direction := 1; {Previous}    
     if Key = VK_DOWN then Direction := 0; {Next}       
     if Direction &lt;&gt; -1 then    
     begin
        if Direction = 0 then cds1.Next else cds1.Prior;
        NextRecord; {Processes AfterScroll event}    
     end; 
  end;
  </code></pre>
  
  <p>This gives me an error <strong>E2008 Incompatible types</strong></p>
  
  <p>What am I doing wrong?</p>