--- ---
You could install a window hook procedure and execute your code each time the ALT key was pressed. Below is a simple example:
{ ... } type TTestEdit = class(TEdit) protected procedure CreateWnd; override; procedure DestroyWnd; override; end; { ... } var Hook: HHook; function GetMsgHook(nCode: Integer; wParam: longint; lParam: longint): longint; stdcall; begin if wParam = VK_MENU then ShowMessage('alt'); Result := CallNextHookEx(Hook, nCode, wParam, lParam); end; procedure TTestEdit.CreateWnd; begin inherited CreateWnd; if (Hook = 0) and not (csDesigning in ComponentState) then Hook := SetWindowsHookEx( WH_KEYBOARD, GetMsgHook, Hinstance, GetWindowThreadProcessId(Handle, nil) ); end; procedure TTestEdit.DestroyWnd; begin if Hook <> 0 then begin UnhookWindowsHookEx(Hook); Hook := 0; end; inherited DestroyWnd; end; initialization Hook := 0;