add directory Ref-docs
This commit is contained in:
19
Ref-docs/manual Bash/abs-guide/abs-guide/keypress.sh
Normal file
19
Ref-docs/manual Bash/abs-guide/abs-guide/keypress.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# keypress.sh: Detect a user keypress ("hot keyboard").
|
||||
|
||||
echo
|
||||
|
||||
old_tty_settings=$(stty -g) # Save old settings.
|
||||
stty -icanon
|
||||
Keypress=$(head -c1) # or $(dd bs=1 count=1 2> /dev/null)
|
||||
# on non-GNU systems
|
||||
|
||||
echo
|
||||
echo "Key pressed was \""$Keypress"\"."
|
||||
echo
|
||||
|
||||
stty "$old_tty_settings" # Restore old settings.
|
||||
|
||||
# Thanks, Stephane Chazelas.
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user