Making the Enter Key act like Tab

Author: Fatih Ölçer 

 

 

 

{

  This code gives the  key the same habbit as the key to

  change focus between Controls.

 

  Mit diesem Code kann man sich mit der Enter Taste zwischen mehreren

  Textfeldern bewegen.(anstatt nur mit der Tabulatortaste)

}

 

// Form1.KeyPreview := True !

 

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);

begin

  if Key = #13 then

  begin

    Key := #0;

    { check if SHIFT - Key is pressed }

    if GetKeyState(VK_Shift) and $8000 <> 0 then

      PostMessage(Handle, WM_NEXTDLGCTL, 1, 0)

    else

      PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);

  end;

end;