| 
    
Forum Index : Microcontroller and PC projects : [Picomite] The best method to clear the keyboard buffer.
| Author | Message | ||||
| twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1662  | 
    
    
 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 KingdomPosts: 1598  | 
    
    
 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: NetherlandsPosts: 5410  | 
    
    
 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: GermanyPosts: 1662  | 
    
    
 @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  | 
  ||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025   |