Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : [Picomite] The best method to clear the keyboard buffer.

Posted: 02:35pm
01 May 2025
Copy link to clipboard
twofingers
Guru


What is the best method to clear the keyboard buffer?
I know this method:
Do :Loop Until Inkey$=""
Do :key$=inkey$:Loop Until key$<>""
...
...

However, I'm not sure if it's the only or the best one. Are there alternatives, e.g., to prevent "overshooting" when scrolling through lists?

Is there a way to adjust the firmware?

Kind regards
Michael
 
Posted: 05:51pm
01 May 2025
Copy link to clipboard
PhenixRising
Guru

I guess it depends on what you're doing but in my case, if there's a character in the RX buffer, I evaluate it with a SELECT-CASE. Use it or lose it.
 
Posted: 07:12pm
01 May 2025
Copy link to clipboard
Volhout
Guru

  twofingers said  What is the best method to clear the keyboard buffer?
I know this method:
Do :Loop Until Inkey$=""
Do :key$=inkey$:Loop Until key$<>""
...
...

However, I'm not sure if it's the only or the best one. Are there alternatives, e.g., to prevent "overshooting" when scrolling through lists?

Is there a way to adjust the firmware?

Kind regards
Michael


The method you describe will work in general (PS2 keyboard/USB keyboard/console). All other methods I know are specific, either to USB or PS2...
In games we use a similar method to your second to keep the last valid key to control the game, the las one before the empty buffer responds with "".

Volhout
Edited 2025-05-02 05:14 by Volhout
 
Posted: 02:06pm
02 May 2025
Copy link to clipboard
twofingers
Guru


@Volhout
Thanks for the confirmation, Harm. It's working great for me right now, too. I just need to figure out why it sometimes doesn't work so well and keeps running uncontrollably.

I vaguely remember that there used to be access to the keyboard ring buffer. I just wanted to make sure I hadn't overlooked anything.


@PhenixRising

Hi,
thanks! Unfortunately, I don't understand your answer. My question was about the "overshooting" when outputting lists (e.g., FM) controlled by the up/down cursor keys. I think that's answered sufficiently.

Kind regards
Michael
 


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025