type TClickObject = class(TObject) public Form: TForm; procedure MyTabOnClick(Sender: TObject); end; { ClickClass } procedure TClickObject.MyTabOnClick(Sender: TObject); var ch: Char; key: Word; begin if Form = nil then Exit; key := vkTab; ch := #9; Form.KeyDown(key, ch, []); end; procedurefunction CreateTabButton(Form: TForm); var Button: TButton; var Count: Integer; ClickObject: TClickObject; begin //Make the click object ClickObject := TClickObject.Create; ClickObject.Form := Form; //Make other buttons not default for Count := 0 to Form.ComponentCount-1 do begin if (Form.Components[Count] is TButton) then //Extend for other buttons ? begin (Form.Components[Count] as TButton).Default := False; end; end; //Make a button far off the screen ButtonResult := TButton.Create(Form); ButtonResult.Parent := Form; ButtonResult.Default := True; ButtonResult.OnClick := ClickObject.MyTabOnClick; ButtonResult.Text := 'TAB'; ButtonResult.Position.X := -10000; ButtonResult.Position.Y := -10000; end; //Form OnShow Event, declare tabButton as TButton in your Form then you can use it on other components like combo boxes where you want to fire tab / enter event tabButton := CreateTabButton(Self); The TComboBox for example does does not place nice with the Button solution, here is an example of making it work
procedure TForm1.CommboBox1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin if (Key = 13) then begin tabButton.OnClick(self); //tabButton declared in the Form an initialized with CreateTabButton end; end;