def keyit(self): self.hm = pyHook.HookManager() self.hm.KeyDown = self.OnKeyBoardEvent self.hm.HookKeyboard() pythoncom.PumpMessages()