I have a TEdit field on a form that has the focus. Is there any way that I can hit the ENTER key and run code that is run when a TButton is pressed?
thanks in advance
Dan Combs
Team
Delphi Developer
Sun, 06 Mar 2005 03:40:47 GMT
Re:TEdit and the ENTER key
On 17 Sep 2002, "Dan" <dancom...@cox.net> wrote:
Quote
> I have a TEdit field on a form that has the focus. Is there any way > that I can hit the ENTER key and run code that is run when a TButton > is pressed?
Write a handler for the Edit's OnKeyPress event:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if Key = #13 then begin Key := #0; Button1Click(Sender); end; end;