title: BASH: read input only once and do not continue reading until key is released
body: <p>I have this short script:</p>
  
  <pre><code>until [[ $ACTION == "t"  ]]; do
  
  read -sn1 ACTION
  
  case $ACTION in
  
   e|E) printf "£\n";;
  
  done
  </code></pre>
  
  <p>When I press "e", a pound sign is printed. When I press and hold "e", I get a continuous stream of "£", one under another.</p>
  
  <p>Is there a way to do this:
  press and hold "e" resulting in only one "£" printed, until the "e" is released and pressed again?</p>
  
  <p>And here is the catch: without the TIMEOUT "-t" switch in <strong>read</strong></p>
  
  <p>Please help :)</p>
  
  <p>============= EDIT one day later ==============</p>
  
  <p>The problem I want to solve is this:
  I can move a symbol on the screen using a combination of tput commands. When the TIMEOUT is set in the <strong>read</strong> command, two things can happen: either the TIMEOUT is big enough, and holding down a key does not move the symbol continuously - but then quick tapping on the key corrupts the screen; or if the TIMEOUT is small, quick tapping does not corrupt the screen, but holding down the key produces ALARM CLOCK interrupt.
  So, I don't want Bash to wait for input. I want it to read a pressed arrow key once, and that's it - user needs to release the key and press again to continue moving.</p>
  
  <p>I have been using this function below, but it's producing all these problems:</p>
  
  <p>ReadKey() 
  {</p>
  
  <pre><code># Wait for first char
  
  if read -sN1 ACTION; then
  
    # Read rest of chars
  
    while read -sN1 -t 0.05 ; do
  
      ACTION+="${REPLY}"
  
    done
  
  fi
  </code></pre>
  
  <p>}</p>
  
  <p>and then</p>
  
  <p>while Readkey; do</p>
  
  <pre><code> case $ACTION in
  
   [case options follow]
  </code></pre>