Contribution: Checking for single Key press with Busybox ash

Denys Vlasenko vda.linux at
Sat Jul 13 22:54:07 UTC 2013

On Friday 12 July 2013 16:44, Harald Becker wrote:
> Hi All,
> as here are many shell script novices, I want to post a simple
> Busybox ash script to check for a single key press. I use this
> during startup to switch from normal operation to rescue mode. If
> no Escape key is pressed within 2 seconds the system starts up in
> normal mode, else a simple rescue shell is invoked via sulogin.
> The script just uses only usual Busybox applets and does not
> need any special program to check the keyboard.
> Script attached ... 
> Comments/questions welcome.

"read -r -t2 -n1 KEY" ?

The downside is that -tSECONDS -nMAXLEN are extensions,
not a standard.


More information about the busybox mailing list