LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2013, 02:38 PM   #1
rrainbolt
LQ Newbie
 
Registered: Oct 2013
Posts: 2

Rep: Reputation: Disabled
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"
 
Old 12-09-2013, 05:26 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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.
 
  


Reply

Tags
tabs


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trap block level read and write request for disk linux_ques Linux - Newbie 2 05-17-2012 01:44 AM
Trap block level read and write request for disk linux_ques Linux - Software 1 05-09-2012 10:11 AM
invisible chrs and no newline in bash after running script with 'trap 2' and 'read' SlackerJack Linux - General 3 08-11-2008 12:03 PM
ncurses-trap key spr_aut Programming 0 04-20-2008 06:16 AM
Tab Key and arrow key zillah Solaris / OpenSolaris 12 05-26-2005 03:51 PM


All times are GMT -5. The time now is 12:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration