code: def run(self):
          
          self.state = True
          if self.capture:
              self.display2.screen().root.grab_keyboard(X.KeyPressMask | X.KeyReleaseMask, X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime)
  
          self.display2.record_enable_context(self.ctx, self.handler)
          self.display2.record_free_context(self.ctx)
docs: Begin listening for keyboard input events.