appevents OnAppKeyDown event
Example
Return to Introduction  Previous page  Next page
Applies to
acAppEvents component.  

Declaration
type  
  TacAppKeyEvent = procedure(Sender: TObject; var Key: Word; Shift: TShiftState; KeyName: String; RepeatedKeypress: Boolean) of object;  
 
property OnAppKeyDown: TacAppKeyEvent;  

Description
The OnAppKeyDown event occurs when user presses any key in ANY window or control within the application. Use the OnAppKeyDown event to process any keypresses in whole program, even if the focus aimed to the control with different handle, in any form within current application process thread.  
 
For example, you would like to minimize your program when user press an "Esc" key. Then just insert following code to the OnAppKeyDown procedure handle:  
procedure TForm1.acAppEvents1AppKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState; KeyName: String; RepeatedKeypress: Boolean);  
begin  
  if not RepeatedKeypress and (Key = VK_ESCAPE) then  
    Application.Minimize;  
end;  
 
tip The OnAppKeyUp handler can respond to all keyboard keys, including function keys and keys combined with the Shift, Alt, and Ctrl keys.  

Parameters
KeyVirtual key code for pressed key (use VK_xx contants, for example, VK_ESCAPE = 27, VK_F1 = 112 and so forth);  
ShiftStateThe state of control keys like Shift, Ctrl and Alt;  
KeyNameThe name of pressed key;  
RepeatedKeypressIs the the key is down before the evvent occurs is sent. This is keypress is repeated if True.  

See also
OnAppKeyUp event.