Advertisement
Guest User

key

a guest
Jan 29th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import pyHook
  2. from pyHook.HookManager import HookConstants
  3. import pygame
  4.  
  5. ctrl_pressed = False
  6. alt_pressed = False
  7. a_pressed = False
  8.  
  9. def OnKeyboardEventDown(event):
  10. global ctrl_pressed
  11. global alt_pressed
  12. global a_pressed
  13.  
  14. if(event.KeyID == HookConstants.VKeyToID('VK_LCONTROL')):
  15. ctrl_pressed = True
  16. if(event.KeyID == HookConstants.VKeyToID('VK_LMENU')): # left alt
  17. alt_pressed = True
  18. if(event.KeyID == 65): # 'a'
  19. a_pressed = True
  20.  
  21. if(ctrl_pressed and alt_pressed and a_pressed):
  22. print("YEAHHHH BUDDY!!!")
  23.  
  24. return True
  25.  
  26. def OnKeyboardEventUp(event):
  27. global ctrl_pressed
  28. global alt_pressed
  29. global a_pressed
  30.  
  31. if(event.KeyID == HookConstants.VKeyToID('VK_LCONTROL')):
  32. ctrl_pressed = False
  33. if(event.KeyID == HookConstants.VKeyToID('VK_LMENU')): # left alt
  34. alt_pressed = False
  35. if(event.KeyID == 65): # 'a'
  36. a_pressed = False
  37.  
  38. return True
  39.  
  40. hm = pyHook.HookManager()
  41. hm.KeyDown = OnKeyboardEventDown
  42. hm.KeyUp = OnKeyboardEventUp
  43. hm.HookKeyboard()
  44.  
  45. # initialize pygame and start the game loop
  46. pygame.init()
  47. while True:
  48. pygame.event.pump()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement