code: def __grabHotkey(self, key, modifiers, window):
          
          logger.debug("Grabbing hotkey: %r %r", modifiers, key)
          try:
              keycode = self.__lookupKeyCode(key)
              mask = 0
              for mod in modifiers:
                  mask |= self.modMasks[mod]
  
              window.grab_key(keycode, mask, True, X.GrabModeAsync, X.GrabModeAsync)
  
              if Key.NUMLOCK in self.modMasks:
                  window.grab_key(keycode, mask|self.modMasks[Key.NUMLOCK], True, X.GrabModeAsync, X.GrabModeAsync)
  
              if Key.CAPSLOCK in self.modMasks:
                  window.grab_key(keycode, mask|self.modMasks[Key.CAPSLOCK], True, X.GrabModeAsync, X.GrabModeAsync)
  
              if Key.CAPSLOCK in self.modMasks and Key.NUMLOCK in self.modMasks:
                  window.grab_key(keycode, mask|self.modMasks[Key.CAPSLOCK]|self.modMasks[Key.NUMLOCK], True, X.GrabModeAsync, X.GrabModeAsync)
  
          except Exception as e:
              logger.warning("Failed to grab hotkey %r %r: %s", modifiers, key, str(e))
docs: Grab a specific hotkey in the given window