Trap key press in a script

How can I trap a character press in the shell script.
For eg:- I have a script runinng a infinite loops , I will need to quit if q is pressed.

I have seen the traping the signal , but they give option only for traping the defined interrupt signals. But those does not help me here.

There is an old thread that might be of help - making a .sh wait for user input

Wow, that was a neat trick.

#!/bin/sh

echo here

while : ; do
  sleep 2
  echo still here
done &

main=$!
echo "# main is $main" >&2


# livinfree's neat dd trick from that other thread vino pointed out
tput smso
echo "Press any key to return \c"
tput rmso
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
dd bs=1 count=1 >/dev/null 2>&1
stty "$oldstty"
echo

kill $main

I agree with era. That was a very neat trick. For a more advanced use of it see: Reading password and echo * character