#!/bin/bash # keypress.sh: Detect a user keypress ("hot keys"). echo old_tty_settings=$(stty -g) # Save old settings (why?). stty -icanon Keypress=$(head -c1) # or $(dd bs=1 count=1 2> /dev/null) # on non-GNU systems echo echo "Key pressed was \""$Keypress"\"." echo stty "$old_tty_settings" # Restore old settings. # Thanks, Stephane Chazelas. exit 0