unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, DBGrids,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
DBGrid1: TDBGrid;
procedure FormCreate(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: char);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
{ Esto puedes hacerlo también en el Inspector de Objetos;
lo pongo aquí y así para que se vea :-) }
KeyPreview := True;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
{Si necesitas un control más "fino", usa OnKeyDown/OnKeyUP }
begin
if (Key = #13) and (Form1.ActiveControl = DBGGrid1) then begin
Key := #00;
Button1.Click.
end;
end;
end.