I have a following small bash script
var=a while true : do echo $var sleep 0.5 read -n 1 -s var done
It just prints the character entered by the user and waits for the next input. What I want to do is actually not block on the read, i.e. every 0.5 second print the last character entered by the user. When user presses some key then it should continue to print the new key infinitely until the next key press and so on.