Maybe try something like this (untested):
procedure TfMain.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
if Key = vkHardwareBack then
begin
Key := 0;
if TabControl.ActiveTab = TabItem1 then
begin
if MessageDlg('Are you sure you want to Exit?', TMsgDlgType.mtWarning, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
begin
MainActivitiy.Finish;
end;
end else
begin
ChangeTabAction1.Execute;
end;
end;
end;