Linux: Anyway to steal keystrokes from plugins?

Some hosts steal all keystrokes from plugins. I’m trying to do this if caps lock is down.

On macOS I do:

    impl->hook = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskKeyDown | NSEventMaskKeyUp handler: ^NSEvent* (NSEvent* ev)
                  {
                      return handleKeypress (ev, capsLock, onKeyPress);
                  }];

on Windows I do:

impl->hook = SetWindowsHookExA (WH_KEYBOARD, hookProc, nullptr, GetCurrentThreadId());

Any Linux experts know if there is anything similar I can do to steal keystrokes from the input message queue?