There are a few ways of detecting keypresses in Delphi.
"OnKeyPress"
FormKeyPress(Sender: TObject; var Key: Char);
This event passes the actual ASCII code in the variable "Key".
"OnKeyDown"
FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
This event passes the windows VK keycode in the variable "Key"
"OnKeyup"
FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
This event passes the windows VK keycode in the variable "Key"
You maybe able to replace your Timer event with the "OnKeyUp" method wich also includes the state of the other keys (shift, ctrl alt) in "Shift".
For instance
Code:
Procedure Form1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
Case Key of
VK_0 .. VK_9 : ; // Number Keys
VK_A .. VK_Z : ; // Aplha Keys
end;
end;
For more information on these events see the Delphi help.
Dave
Enter your message below
Sign in or Join us (it's free).