#๐Ÿ”’ Can't seem to get the expected output :/

4 messages ยท Page 1 of 1 (latest)

split rock
#

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.

source:
https://paste.pythondiscord.com/ADAQ

dreamy bronzeBOT
#

@split rock

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dreamy bronzeBOT
#

@split rock

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.