# How to read arrow keys on really old bash?

**URL:** <https://community.unix.com/t/how-to-read-arrow-keys-on-really-old-bash/161344>\
**Category:** Shell Programming and Scripting\
**Created:** [May 1, 2006, 7:05am UTC](https://community.unix.com/t/how-to-read-arrow-keys-on-really-old-bash/161344 "2006-05-01T07:05:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonb](https://community.unix.com/letter_avatar/simonb/32/6_22734026db12803ebb3e059622ac3534.png) [@simonb](https://community.unix.com/u/simonb)\
**Post date:** [May 1, 2006, 7:05am UTC](https://community.unix.com/t/how-to-read-arrow-keys-on-really-old-bash/161344/1 "2006-05-01T07:05:52Z")

</div>

I would like to get a script to respond to arrow key presses to scroll up and down a menu.

The platform is CDLinux which uses a prehistoric version of bash, version 1.14.7.

I would like to do something like "read -sn 1 keyin" but the "read" command is so primative that it only has the -r switch available so it is not possible, as far as I can see, to read single keystrokes, only whole lines.

Is there any way to detect arrow keys in this backwater of a bash shell?

---

<div class="post-metadata">

**Author:** ![simonb](https://community.unix.com/letter_avatar/simonb/32/6_22734026db12803ebb3e059622ac3534.png) [@simonb](https://community.unix.com/u/simonb)\
**Post date:** [May 1, 2006, 10:27am UTC](https://community.unix.com/t/how-to-read-arrow-keys-on-really-old-bash/161344/2 "2006-05-01T10:27:11Z")

</div>

OK. Found out how to do it.

```php
stty_state=`stty -g`
stty raw; stty -echo
keycode=`dd bs=1 count=1 2>/dev/null`
stty "$stty_state"

```

Where keycode contains the key code.
