Posted: 28th Mar 2021 21:00
Good day. I have a coding question which is how do I reset the keyboard press state. I want to use the enter key and then use it again but it remembers it;s been pressed and does the second key press automatically .
Any help would be appreciated . Thanks for reading ..
Posted: 28th Mar 2021 21:12
sync() will reset the keyboard.
Im not sure which particular subcommand does that but you could try
Update() and/or Render() to see if either one of those clears the keyboard
Posted: 28th Mar 2021 21:18
Ok thanks i'll have a play and will post back when I find the answer.
Posted: 28th Mar 2021 21:54
Well I'm not sure if this is the correct way to do it but this works.
sync()
sync()
sync()
sync()
sync()

sync() 5 times works fine .
I've found 7 times works the best . Just thought I would share . If anybody knows a better way and there must be one please feel free to enlighten me . Thanks for the help.
Posted: 29th Mar 2021 2:18
It'll be easier to help you if you provide a code snippet that demonstrates the issue. Are you using GetRawKeyState() or GetRawKeyPressed()? GetRawKeyPressed() is what you want to use here, as it will return 1 for one frame only once the key has been pressed, and 0 on all subsequent frames until the key is pressed again. You definitely shouldn't be calling sync() 5 times in a row. You really should only be calling it once at the end of your main loop in 99.9% of cases.
Posted: 29th Mar 2021 8:42
Thanks Hedron yes it was for getrawkeystate. will try and use get rawkeypressed () and see what happens.