|
readkey() and sticking |
SkaxCo
Member #8,323
February 2007
|
I'm trying to use readkey to move a character across the screen. If you hold down the key, it backlogs the keyboard. Is there any way to clear the keyboard buffer? Like keyboard_clear() or something like that? |
Kauhiz
Member #4,798
July 2004
|
clear_keybufR.T.F.M... --- |
SkaxCo
Member #8,323
February 2007
|
Thanks |
Kauhiz
Member #4,798
July 2004
|
Sorry, edited --- |
Albin Engström
Member #8,110
December 2006
|
I'm putting in a little question: when would clear_keybuf be needed? because i've never used it and everything works great..? |
Kauhiz
Member #4,798
July 2004
|
...Please just RTFM, please! --- |
Kris Asick
Member #1,424
July 2001
|
If you're using readkey() for movement, EXPECT backlog. You want to be reading the key[] array instead if you want constant movement. If however you want the ability to move single spaces AND constantly, one method you can do is to check both readkey() and key[] at the same time and only move the character if BOTH return the appropriate value. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Albin Engström
Member #8,110
December 2006
|
Kris Asick: Noted, thanks. |
Bill Morris
Member #3,734
July 2003
|
For some applications, you might want to set the delay and repeat rates, with set_keyboard_rate(delay, repeat). Default is 250, 33 (milliseconds). You might want to set it for high speed and use rest() to slow it down where necesary, to vary the speed as the program may require. But clear_keybuf() is definitely useful for the problem you mentioned. I use in my text editors to reprevent buffer overload when scrolling. |
gnolam
Member #2,030
March 2002
|
... no. For the situation the OP mentioned, the key[] array is the way to go. And you basically never want to use rest() except to yield to the OS. -- |
|