Last active
September 4, 2015 18:05
-
-
Save voltuer/c5d3b98284b0015ba0a4 to your computer and use it in GitHub Desktop.
Captura flechas del teclado y mouse usando buffer alternativo (smcup)
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 | |
#script que lee Arriba y Abajo de teclado y mouse y al matarlo vuelve a mostrar el buffer anterior de la consola ~seb.cl | |
#se usa `stty echo` al salir para q vuelva a activarse el echo de la consola, desactivado por `read` | |
#además a nivel de script desactivé todo el echo para poder usar el scroll del mouse sin que se vean signos raros | |
stty -echo | |
tput smcup | |
trap "tput rmcup;stty echo;exit" KILL INT | |
printf "Usa las flechas del teclado o el scroll del mouse\n\n" | |
while :;do | |
read -r -sn1 t #capturar 1 tecla, ignorando retornos, con 1ms de timeout, en la variable $t | |
case $t in | |
A) echo Arriba;; | |
B) echo Abajo;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment