I have a bash loop that waits for a single key press, then does $something depending on what $key is pressed before refreshing the screen with updated data. The problem I have is that the script will store additional key presses and chain them together causing the screen to redraw and the script seemingly halt while the backlog of key presses get ran. Is there any way to force the script to wait and/or discard additional key presses until the screen finishes a single refresh. Script looks similar to the below
#!/bin/bash
default vars
loop
drawscreen
wait for input
if 'a'
do something
back to top of loop
if 'b"
do anything
back to top of loop
if 'c'
break
done
I am using 'read -n1 -e answer' for input if that makes a difference