code: def check_return_space(event, callable_):
      
      if event.type() == QEvent.KeyPress:
          if event.key() in [Qt.Key_Return, Qt.Key_Space]:
              callable_()
              return True
      return False
docs: Checks if event corresponds to Return/Space being pressed and calls callable_ if so.