Debian Codegraph @

dd-keypress.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # dd-keypress.sh: Capture keystrokes without needing to press ENTER.
3
4
5 keypresses=4 # Number of keypresses to capture.
6
7
8 old_tty_setting=$(sttyscip-shell system . . stty. -g) # Save old terminal settings.
9
10 echoscip-shell system . . echo. "Press $keypresses keys."
11 sttyscip-shell system . . stty. -icanon -echo # Disable canonical mode.
12 # Disable local echo.
13 keys=$(ddscip-shell system . . dd. bs=1 count=$keypresses 2> /dev/nullscip-shell filesystem . . `/dev/null`.)
14 # 'dd' uses stdin, if "if" (input file) not specified.
15
16 sttyscip-shell system . . stty. "$old_tty_setting" # Restore old terminal settings.
17
18 echoscip-shell system . . echo. "You pressed the \"$keys\" keys."
19
20 # Thanks, Stephane Chazelas, for showing the way.
21 exit 0