The python code i made is used to capture certain user keyboard input (w, a, s, d, r, t, 'space') and output it into console and log files, it also has trigger key to either start the key capture or not, when in 'True' it will start capturing the keyboard key input, else in 'False' it will block the input and doesn't output anything.
The issue is that, the only output it gave me is the 'SPACE' button, while other key doesn't output anything, and there are no error message.
Valid key mappings:
{'W': 'W', 'A': 'A', 'S': 'S', 'D': 'D', 'R': 'R', 'T': 'T', 'SPACE': 'SPACE'}
Key capture started. [True]
[2024-04-06 08:31:03] Key [SPACE] was pressed for [0.56] seconds.
[2024-04-06 08:31:03] Key [SPACE] was pressed for [0.11] seconds.
[2024-04-06 08:31:05] Key [SPACE] was pressed for [1.33] seconds.
Key capture paused. [False]
Expected output:
{'W': 'W', 'A': 'A', 'S': 'S', 'D': 'D', 'R': 'R', 'T': 'T', 'SPACE': 'SPACE'}
Key capture started. [True]
[2024-04-06 08:31:03] Key [W] was pressed for [0.56] seconds.
[2024-04-06 08:31:05] Key [A] was pressed for [0.11] seconds.
[2024-04-06 08:31:07] Key [S] was pressed for [0.20] seconds.
[2024-04-06 08:31:08] Key [D] was pressed for [0.10] seconds.
[2024-04-06 08:31:10] Key [R] was pressed for [0.30] seconds.
[2024-04-06 08:31:12] Key [T] was pressed for [0.22] seconds.
[2024-04-06 08:31:18] Key [SPACE] was pressed for [1.33] seconds.
Key capture paused. [False]
And i don't really know what's wrong with it, i thought it's because something in on_release or on_press variable, but it doesn't fix it.