Casing arrow keys in bash

前端 未结 8 843
遥遥无期
遥遥无期 2020-12-10 06:45

Is it possible to case arrow keys in a bash script to run a certain set of commands if the up/left arrow keys are pressed, and a certain set if the down/right arrow keys are

8条回答
  •  爱一瞬间的悲伤
    2020-12-10 07:03

    # This will bind the arrow keys
    
    while true
    do
        read -r -sn1 t
        case $t in
            A) echo up ;;
            B) echo down ;;
            C) echo right ;;
            D) echo left ;;
        esac
    done
    

提交回复
热议问题