Capture keyboard input without window focus


Hello everyone,
i need a suggestion, i have a GTK app that start without a window when i
press shift+ctr+p a window should be shown.

My current try is like follow its not really nice but its nearly working

The code below is only working when the focus/cursor is on a window this
is not possible because its hidden, is there a opportunity to catch it
global from X ? or do i need a dummy window in the background ?

Gtk.key_snooper_install{|w, e|
@key_input.push e.hardware_keycode
#puts β€œcode=#{e.hardware_keycode}”
#puts β€œl =#{@key_input.length}”

@key_input.clear unless([33,37,64].include? e.hardware_keycode or
@key_input.length < 4)

if @key_input.include?(33) and @key_input.include?(37) and
@key_input.include?(64) then

   # show cusor that was hidden
   #do my action / unhide my window


thanks ahead!

kind regards