Quote from: Thaddy on January 25, 2022, 06:41:11 amCode: Pascal [Select][+][-]procedure TInpUsrFrm.DBGrid1KeyPress(Sender: TObject; var Key: char);begin if key = VK_RETURN then ShowMessage(Ord(Key), 'Enter pressed'); end Might work.;
Code: Pascal [Select][+][-]procedure TInpUsrFrm.DBGrid1KeyPress(Sender: TObject; var Key: char);begin if key = VK_RETURN then ShowMessage(Ord(Key), 'Enter pressed'); end Might work.;
Both codes unable to capture ENTER key.
Quote from: incendio on January 26, 2022, 02:50:12 amBoth codes unable to capture ENTER key.Why don't you use OnKeyDown (or OnKeyUp) event as Zoran suggested?This code works for Enter key:Code: Pascal [Select][+][-]procedure TForm1.DBGrid1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin ShowMessage(Key.ToString);end;
What is wrong with Keypress?
Is it a bug that Keypress does not work on ENTER key?
What is wrong with Keypress?Is it a bug that Keypress does not work on ENTER key?
This handler only receives characters, not control or other special key codes. Control keys should be handled by an OnKeyDown handler instead.