LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   shell for READKEY (http://www.linuxquestions.org/questions/linux-general-1/shell-for-readkey-24107/)

Rex_chaos 06-23-2002 03:08 AM

shell for READKEY
 
Hello all,
I would like to write a shell to read a UP, DOWN, LEFT and RIGHT key in and output a corresponding message. However, I found "read" function don't know how to read the special key as the key value. Does anyone have idea?

Thanks.

kop 06-28-2002 06:34 PM

I don't think there is a "special value", just some odd characters.


[root@mofo X11]# cat -v -
^[[A
^[[A


(I typed the up arrow key, then the return key, then Ctl-d.)

So, up arrow is Ctl-[, followed by [, followed by A.

You may need to turn off command line editing with --noediting
when starting the shell, or you may never see the keys used for editing...

Have your script start with
#!/bin/bash --noediting

(I think.)

(man bash)


All times are GMT -5. The time now is 11:04 AM.