Component shouldn't lose focus when tab is pressed lazarus / 31-LCL ---------------------------------------------------------------------- Yakumo500 · 2010-11-18 18:16 Hi, currently I'm writing an editor component and I have a problem with the tab key. It's recognized by KeyDown but my control will lose focus. How could I change that? ---------------------------------------------------------------------- typo · 2010-11-18 18:23 Your component is a descendant of what? SetFocus should be sufficient. ---------------------------------------------------------------------- Yakumo500 · 2010-11-18 18:31 It's a descendant of TCustomControl. ---------------------------------------------------------------------- typo · 2010-11-18 18:39 SetFocus can restore the focus to your control. ---------------------------------------------------------------------- Yakumo500 · 2010-11-18 18:49 But if I write SetFocus in Keydown or Keypress or Keyup nothing happens. I think the focus change happens after Keydown and Keypress and Keyup are executed. ---------------------------------------------------------------------- typo · 2010-11-18 19:00 Have you tried to set Key := #0 on the KeyPress event or Key := 0 on the KeyDown event? Code: [Select]procedure TYourControl.ComponentKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin   // uses Windows unit   if Key = VK_TAB then     Key := 0; end; ---------------------------------------------------------------------- Yakumo500 · 2010-11-19 15:19 Oh it's so easy and I didn't get it. Thank you.