I can get read -n 1 KEY to get most keys, except for keys which are represented by multiple characters. For example, if I press the up arrow key:
$ read -n 1; echo
^[[A
$ [A
As you can see, read only takes the Esc and the [A is left over.
What I want to be able to do in a script is:
- Go through a list with the arrow keys and press Enter to do something with it
- For other actions, press different keys.
You are better off using dialog as jm666 mentioned, but there are other ways to skin that cat.
Basically wait until you read a character and then spin consuming input until .1 seconds has passed w/o input.
Warning, fast typists could get annoyed. You might need to tweak that timeout.