A
A
akdes2015-11-11 01:09:04
Python
akdes, 2015-11-11 01:09:04

Python loses keypress event as soon as another one is pressed, how to avoid?

Hi all.
I am writing a small script. Should catch the spacebar, and not lose it if they hit the clave.

def get_space_state():
    hllDll = ctypes.WinDLL ("User32.dll")
    VK_SPACE = 0x20
    return hllDll.GetKeyState(VK_SPACE)

while (True):
        print get_space_state()

I hold the spacebar, writes -127 / -128, in principle they will arrange it.
But as soon as I start poking other keys without releasing the spacebar, the event is lost, and the status of the spacebar is 0.
Any ideas how to fix it? Need as in games, forward arrow: gas, but you can still steer at the same time, without losing the gas hook
Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nirvimel, 2015-11-11
@akdes

You can use Get Async KeyState for example.
Read more about the reasons for this behavior and the differences between GetAsyncKeyState and GetKeyState here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question