{$MODE OBJFPC}
{$LONGSTRINGS ON}
uses x, sysutils, xlib, keysym;

var
dpy : PDisplay;
root : TWindow;
ev : TXEvent;
modifiers : DWord;
keycode, pointer_mode, keyboard_mode : LongInt;

begin
dpy := XOpenDisplay(nil);
root := DefaultRootWindow(dpy);
modifiers := ControlMask OR ShiftMask;
keycode := 45;
pointer_mode := GrabModeAsync;
keyboard_mode := GrabModeAsync;
XGrabKey(dpy, {AnyKey} XK_F12, modifiers, root, 0, pointer_mode, keyboard_mode);
XSelectInput(dpy, root, KeyPressMask);
while true do begin
XNextEvent(dpy, @ev);
if ev._type = KeyPress then begin writeln('key has been pressed'); break; end else writeln('event type is ', ev._type);
end;
end.