home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1997 January / pcpro-0197.bin / Code / Unix / listing1.txt
Encoding:
Text File  |  1996-11-01  |  424 b   |  21 lines

  1. GetUserKeyStroke()
  2. {
  3. # Save Old Tty setting
  4. oldTtySettings="`stty -g`"
  5.     
  6. # Set echo off and raw mode on
  7. stty -echo raw
  8.     
  9. # Get the keystroke from the user
  10. userKeyStroke="`dd bs=1 count=1 2> /dev/null`"
  11.     
  12. # Return character to calling program
  13. echo "$userKeyStroke"
  14.     
  15. # Display character on the screen
  16. echo "$userKeyStroke\c" >&2
  17.     
  18. # Restore the previous tty settings
  19. stty $oldTtySettings
  20. }
  21.