Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 02:30 03 May 2025 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: 1520
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
causality ≠ correlation ≠ coincidence
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1134
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: 4819
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: 1520
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
causality ≠ correlation ≠ coincidence
 
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 2025