Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On "Esc" key press

Status
Not open for further replies.

beginner81

Programmer
Oct 27, 2003
44
MY
Can anyone there help me with this problem .. i'm intended to prompt out a msg dialog after the users press the "Escape" key.. so what's the code for it??
thx in advance..
 
On your form add this event

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (ord(Key)=27) then // if key is ESC
ShowMessage('your text');
end;
// a better message box is MessageDlg();



Good Luck !
Spent
mail:spentbg@yahoo.com
 
Add this event in your form.

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #27 then ShowMessage('Esc key is press.');
end;

or

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_ESCAPE then ShowMessage('Esc key is press.');
end;

Note: You can not use Virtual Keys (VK_) in KeyPress event.

FITZ
email: LANThel@go.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top