0

I want something that allows me to get multiple characters pressed at the same time, so that something in a game I'm making can move diagonally instead of only the four basic directions. I have found a few things on the internet, but I preferably would like something that does not require installation of a module, as I'm firstly not sure how to install a module and secondly want to be able to move my code to to other computers and have it run without installation of the module. This is probably possible, but i'm not sure how to do that. I tried using msvcrt.getch()

import msvcrt
while True:
  print(msvcrt.getch())

But that only gets one character. I'm wondering if what im asking for is possible using threading and getch or something, or just something other than getch(). I am also using Windows.

If this is impossible without installed modules, tell me how to install a module and how to do what I want using it.

user2977984
  • 13
  • 1
  • 1
  • 4

1 Answers1

0

Since you are using msvcrt, I am assuming you are on Windows. You can have a look at the pyhook module to access keyboard events. The module is pretty simple to use and the Tutorial gives you pretty much everything you need to go.

You can also have a look at Using pyhook to respond to key combination (not just single keystrokes)? to have an idea on how to use it.

Community
  • 1
  • 1
Rod
  • 52,748
  • 3
  • 38
  • 55
  • Thank you, I guess I'll use this as I don't think there will be any completely satisfying answer, but if you or anyone finds a way to do it with only the modules that come with python, I would like that. – user2977984 Nov 27 '13 at 06:15