shell读取键盘上下左右的问题?
方向键值查出来的,应该没错。不知哪里有错,请教。
代码如下
#!/bin/sh
uparrowkey='^[[A'
downarrowkey='^[[B'
leftarrowkey='^[[D'
rightarrowkey='^[[C'
#---------------------------------------------------
echo "Press a control key then hit return"
read KEY
echo $KEY
case $KEY in
$uparrowkey)
echo "UP Arrow"
;;
$downarrowkey)
echo "DOWN Arrow"
;;
$leftarrowkey)
echo "LEFT Arrow"
;;
$rightarrowkey)
echo "RIGHT Arrow"
;;
*)
echo "UNKNOW KEY $Key"
;;
esac
埃尼默兽瞳
12 years, 4 months ago