Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:01 07 Sep 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

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

Author Message
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1769
Posted: 02:35pm 01 May 2025
Copy link to clipboard 
Print this post

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
‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 2076
Posted: 05:51pm 01 May 2025
Copy link to clipboard 
Print this post

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.
 
Volhout

Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 6090
Posted: 07:12pm 01 May 2025
Copy link to clipboard 
Print this post

  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
PicomiteVGA PETSCII ROBOTS
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1769
Posted: 02:06pm 02 May 2025
Copy link to clipboard 
Print this post

@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
‚My name is Ozymandias, king of kings
Look on my works, ye Mighty, and despair!‘
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and ...
 
Print this page


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

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