Regarding automatic keystroke

Hi All ,

I am writing a shell script for a 3D test case . The 3D Test case involves the user to press some keys to see the changes in the 3d test case . The user has to press p , r , a , z etc to observe the changes on screen .
Now please let me know how can i implement the keystroke p , a , etc automatically . I need the shell script to accept the keystrokes p ,a , r , etc without user interaction .

Regards,
Deepak

This way (in ksh) :

#!/usr/bin/ksh

readKey () 
{
echo "Press key."
oldstty=$(stty -g)
stty -icanon -echo min 1 time 0
answ=$(dd bs=1 count=1 2>/dev/null)
stty "${oldstty}"
oldstty=""
}

readKey

echo "${answ} --> presed"