Skip to content
Sign upLog in
← Back to Community
trouble with pygame keyboard input
Profile icon
EthanCulp

Whenever I press "w", it wont register my input. It isn't the code inside of the if statement because it isn't even printing "w"

https://repl.it/@EthanCulp/Game

Answered by Zavexeon [earned 5 cycles]
View Answer
Voters
Profile icon
LUIGIBURELLI
Profile icon
EthanCulp
Comments
hotnewtop
Profile icon
Zavexeon

Try forking the repl. The repl might just be broken.

Profile icon
EthanCulp

@Zavexeon
I have already solved the problem but that is basically what I did. The problem was with repl.it so I just marked yours as the answer. I just copy and pasted the code to Visual Studio Code (A great coding program) and it worked.

Profile icon
MATTHEWBECHTEL

I can’t help you but I have a feeling it has something to do with.
y += vel
It just doesn’t look right.

Profile icon
EthanCulp

that isn't the problem, when this is line is outside the if statement, it works just fine, but it won't stop moving. I need it so that when I press the "w" key, the y value will have vel subtracted from it (and yeah i know, it is supposed to be y -= vel to make it go up).

Profile icon
MATTHEWBECHTEL

I don’t know. I can’t help.


@EthanCulp

Profile icon
EthanCulp
Profile icon
Zavexeon

@MATTHEWBECHTEL
That's a valid operator, +=.

For example you could do:
x += 1
which is the equivalent of...
x = x + 1

Profile icon
MATTHEWBECHTEL

I don’t know, I don’t do functions.

@Zavexeon