Utilizing func keys in scripts

I would like to have the function keys available to me in my scripts. Anyone have any ideas on how to map these to functionality I design? :confused:

Hi,
Well after some research this is what i can say.
I use k-shell. on the prompt, if I press the ctrl-v and then the F1 key, i see the characters ^[OP. these are 3 characters. So I wrote a small function getch as follows

function getch {
stty raw
typeset x
x=`dd bs=1 count=3`
stty -raw
echo $x
}

So when I have to check for say F1 in a script I use it as
keyPressed=`getch`
if [ "${keyPressed}" = "^[OP" ]; then
## the ^[OP is not those characters, but it is 3 characters that i get after typing ctrl-v followed by F1
echo " You typed F1"
fi

Hope this helps.

First off, thank you for your effort it is much appreciated. Secondly, can you explain each step in you getcha function.

Hmm.

The stty command allows you to map control keys to tty functions like erase

 stty erase "^H" kill "^U" intr "^C" eof "^D" susp "^z" kill "^o"

This example sets ^C (control/c) to intr (interrupt), backspace ^h to erase....and so on.

Some terminal emulators allow you to map functions keys to actual UNIX commands,
but this is not specific to UNIX itself. An example is secureCRT from Vandyke Technologies.