Для начала необходимо установить свойство формы KeyPreview в True.
А потом уже можно отлавливать "Esc":
procedure
TForm1.FormCreate(Sender: TObject);
begin
Form1.KeyPreview := True;
end;
procedure
TForm1.FormKeyPress
(Sender: TObject; var Key: Char);
begin
if key = #27 then Close;
end;
Взято
из http://forum.sources.ru