Monday, April 6, 2015

Keystroke detection

Program (keystroke.sh)
# Detect key stroke
echo "Hit a key and then hit return."
read Keypress
case "$Keypress" in
[[:lower:]] ) echo "Lowercase letter";;
[[:upper:]] ) echo "Uppercase letter";;
[0-9] ) echo "Digit";;
* ) echo "Punctuation, whitespace, or other";;
esac

Output
[vijai@localhost command]$ sh keystroke.sh
8
Digit

No comments:

Post a Comment