I'm trying to do the following thing:
Store keypress state in a list (False or True values) then if I press or unpress some key the list will be printed only if it's content changes and only once. (Keypress in this case)
I tried checking W A S D keys:
import keyboard
# List initializing
list = [False, False, False, False]
previous_list = [False, False, False, False]
while True:
list[0] = keyboard.is_pressed("w")
list[1] = keyboard.is_pressed("a")
list[2] = keyboard.is_pressed("s")
list[3] = keyboard.is_pressed("d")
if list != previous_list:
print(list)
previous_list = list
Can you guys help me discovering why isn't it working ?
Thanks !!