How to implement hot key in Delphi

It's very simple. Just drop THotKeys component onto your form and register your hot key with RegisterKey or RegisterShortCut methods.

cmpHotKeys.RegisterShortCut(htkHotKey.HotKey); // htkHotKey is a THotKey control
cmpHotKeys.RegisterKey(VK_F12,[ssCtrl]]); // Ctrl+F12 is registering

You can register as many hot keys as you need with single THotKeys component. To activate component set Active property to True or call Resume method.

When component is active and user presses registered hot key, the OnHotKey event fires with passed key and shift state.

procedure TfrmHotKeysMain.cmpHotKeysHotKey(Sender: TObject; Key: Word;
  Shift: TShiftState);
begin
  SetForegroundWindow(Handle);
  Application.MessageBox(
    PChar('The "'+ShortCutToText(ShortCut(Key,Shift))+'" hot key is pressed.'),
    'Hot Key',
    MB_OK or MB_ICONINFORMATION);
end;

To unregister hot key call UnregisterKey ot UnregisterShortCut method. Also you can unregister registered hot key with UnregisterIndexKey. Pass key index returned by RegisterKey or RegisterShortCut methods. UnregisterAllKeys unregisters all your registered hot keys.

You can stop and resume all your registered hot keys with Pause and Resume methods or by direct manipulating with Active property.

OnChange event fires when set of your registered hot keys is changed.

See also
Hot Keys
Keyboard Hook
Components for Delphi / C++ Builder
Howtos for Programmers