I want to ask the user to press any key before the program continues and have written this.
ccWaitForKeyOrMouse() works fine *once* BUT, it you call it again, say on the next screen and the user has held the key down without releasing it, it will immediately say "yep a key has been pressed" and not wait at all. Which strictly is true due to the key repeating. FlushKeys doesn't work because it only kills what's currently in the buffer and as soon as the next key comes through due to key repeat, the user is allowed to progress.
I have got round this before by saying press SPACE to continue and using KeyDown(57) by tracking when it released and only letting them progress if they released the key before pressing it again. But there is no way to do this with ALL keys except for writing a stupid for loop to test all keys.
So in summary can anyone think of a decent way to allow the user to press any key to progress but one which ignores key repeats due to it being held down so the user is forced to lift their finger and press again? Hope I've made this clear.
Thanks in advance
;some code ... ccWaitForKeyOrMouse flip ;some more code ccWaitForKeyOrMouse flip Function ccAnyKeyPressed() Local TheKey = 0 TheKey = GetKey() ;erase arrow keys already held down as flush keys doesn't do it! If TheKey >= 63232 And TheKey <= 63235 Then TheKey = 0 Return TheKey End Function Function ccWaitForKeyOrMouse() ;Flushing twice is important to clear out before and after ccFlushAll() While ccAnyKeyPressed() = 0 And GetMouse() = 0 Wend ccFlushAll() End Function Function ccFlushAll() FlushKeys FlushMouse End Function
ccWaitForKeyOrMouse() works fine *once* BUT, it you call it again, say on the next screen and the user has held the key down without releasing it, it will immediately say "yep a key has been pressed" and not wait at all. Which strictly is true due to the key repeating. FlushKeys doesn't work because it only kills what's currently in the buffer and as soon as the next key comes through due to key repeat, the user is allowed to progress.
I have got round this before by saying press SPACE to continue and using KeyDown(57) by tracking when it released and only letting them progress if they released the key before pressing it again. But there is no way to do this with ALL keys except for writing a stupid for loop to test all keys.
So in summary can anyone think of a decent way to allow the user to press any key to progress but one which ignores key repeats due to it being held down so the user is forced to lift their finger and press again? Hope I've made this clear.
Thanks in advance