Skip to content

Instantly share code, notes, and snippets.

@roktas
Created April 13, 2014 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roktas/10599096 to your computer and use it in GitHub Desktop.
Save roktas/10599096 to your computer and use it in GitHub Desktop.
getch() {
local saved=$(stty --save)
stty raw -echo
eval $1=$(dd bs=1 count=1 2> /dev/null)
local status=$?
stty $saved
return $status
}
getch() {
read -s -n1 $1 >/dev/null 2>&1
}
getch A; echo "User pressed '$A'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment