johnslattery
3/30/2017 - 2:17 PM

Capture a key press to trigger some action.

Capture a key press to trigger some action.

# Press ‘c’ to cancel, any other key to continue.
read -s -n1 -p $'Press c to cancel. Any other key to continue.\n' \
  keypress
if [[ $keypress = c ]]
then
  exit
fi