unit UMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Label1: TLabel;
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  hook: HHOOK;

implementation

{$R *.dfm}

function KeyboardProc(nCode: Integer; wParam : WPARAM; lParam: LPARAM): Integer; stdcall;
var
  F: Boolean;
begin
  if (nCode < 0) then
    CallNextHookEx(hook, nCode, wParam, lParam);

  F := False;

  if (nCode = HC_ACTION) then
    if (wParam = WM_KEYDOWN) then
      if (GetAsyncKeyState(VK_CONTROL) <> 0) then
      begin
        Form1.ListBox1.Items.Clear();
        Form1.ListBox1.Items.Add('Сработало!');

        F := True;
      end;

  if (F) then
    Result := 1
  else Result := CallNextHookEx(hook, nCode, wParam, lParam);
end;

procedure TForm1.FormShow(Sender: TObject);
const
  WH_KEYBOARD_LL = 13;
begin
  hook := SetWindowsHookEx(WH_KEYBOARD_LL, @KeyboardProc, GetModuleHandle(nil), 0);
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  UnhookWindowsHookEx(hook);
end;

end.
