This site hosted by Free.ProHosting.com
Google

How can I detect character key presses?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

How can I check if a certain character was pressed?
 
 1.
  Start a new project using File | New Application.
 
 2.
  Double-click the OnKeyPress event:
 
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
    ShowMessage("You pressed " + String(Key));
}
 
The OnKeyPress event lets you handle key presses. Its Key parameter contains the name of the key.

C++Builder Developer's Network
Copyright © Yoto Yotov