How can I trap the TAB key in a read
if I have a simple form, let's say
NAME: ADDRESS: CITY: ZIP: and I want to tput cup 0 6; read name I want to be able to detect that the user either hit enter OR tabs down to the next field, (not just a tab to the right) So basically I need to know the user hit tab and then place the cursor on the next field ready for more input, in this case: tput cup 1 9; read address. this is just a simple example, my actual need is on a more complex customer entry form so I don't want to echo a new line of info after each "enter" |
You can always set the tab key to be a break character and catch that. See the manpage on stty for that.
It has been over 20 years since I've done stuff like that, but you can go through the terminfo database table on what characters do what... (both input and output). For bash you can look into the READLINE builtin - it allows an Emacs-style notation to denote keystrokes and you should be able to use that for catching anything else you may want to do. |
All times are GMT -5. The time now is 11:25 PM. |