Created
December 2, 2013 02:42
-
-
Save mdawaffe/7744188 to your computer and use it in GitHub Desktop.
Terminal Arrow Keys Experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
uparrow=$'\x1b[A' | |
downarrow=$'\x1b[B' | |
leftarrow=$'\x1b[D' | |
rightarrow=$'\x1b[C' | |
read -s -n3 -p "Hit an arrow key: " x | |
case "$x" in | |
$uparrow) | |
echo "You pressed up-arrow" | |
;; | |
$downarrow) | |
echo "You pressed down-arrow" | |
;; | |
$leftarrow) | |
echo "You pressed left-arrow" | |
;; | |
$rightarrow) | |
echo "You pressed right-arrow" | |
;; | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment