#!/bin/ksh ################################################################ #### Korn Shell function to read one character from #### standard input (STDIN) without requiring a carriage #### return. This function would typically be used in a #### shell script to detect a key press. #### #### Load this file into your current environment as follows: #### #### . ./getch.sh #### #### Thats "dot-space-dot-slash-getch-dot-sh" #### #### You will then be able to issue the command "getch" #### from your current environment to retrieve one character. #### #### SYNTAX: getch [quiet] #### #### quiet = no output #### #### #### AUTHOR: Dana French #### EMAIL: dfrench@xoommail.com #### ################################################################ getch() { STAT_GETCH="0" stty raw TMP_GETCH=`dd bs=1 count=1 2> /dev/null` STAT_GETCH="${?}" stty -raw if [[ "_${1}" != "_quiet" ]] then print "${TMP_GETCH}" fi return ${STAT_GETCH} } ################################################################