dd-keypress.sh

来自「Shall高级编程」· Shell 代码 · 共 22 行

SH
22
字号
#!/bin/bash# dd-keypress.sh: Capture keystrokes without needing to press ENTER.keypresses=4                      # Number of keypresses to capture.old_tty_setting=$(stty -g)        # Save old terminal settings.echo "Press $keypresses keys."stty -icanon -echo                # Disable canonical mode.                                  # Disable local echo.keys=$(dd bs=1 count=$keypresses 2> /dev/null)# 'dd' uses stdin, if "if" (input file) not specified.stty "$old_tty_setting"           # Restore old terminal settings.echo "You pressed the \"$keys\" keys."# Thanks, Stephane Chazelas, for showing the way.exit 0

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?