Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] How to clear keypress buffers

Author
Message
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
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 ..

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
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
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 28th Mar 2021 21:18
Ok thanks i'll have a play and will post back when I find the answer.
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 28th Mar 2021 21:54 Edited at: 29th Mar 2021 01:30
This post has been marked by the post author as the answer.
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.
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 29th Mar 2021 02: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.
Pfaber1
6
Years of Service
User Offline
Joined: 7th Jan 2018
Location: England
Posted: 29th Mar 2021 08:42
Thanks Hedron yes it was for getrawkeystate. will try and use get rawkeypressed () and see what happens.

Login to post a reply

Server time is: 2024-11-21 17:24:49
Your offset time is: 2024-11-21 17:24:49