peter-murach/tty — pull request #11 by janko-m (2014-11-27 10:57:16+00:00)
Title: Add #read_keypress to Shell

Sometimes we want to read a single keypress from the user. This will read any keypress, no matter how many characters it is.

```rb
require "tty"

shell = TTY::Shell.new
key = shell.ask("Press a key: ").read_keypress

case key
when "\e[A" then puts "Up"
when "\e[B" then puts "Down"
when "\e[C" then puts "Right"
when "\e[D" then puts "Left"
...
end
```

I didn't know how to write tests for it, because it wouldn't work on `StringIO`s (since it's a Terminal option). I wanted to somehow use `IO#raw`, but it seemed to complicated, because `IO#raw` already includes disabling echo. And if I did that, then I would also have to use `IO#noecho` for echoing to be consistent :smiley:

Fixes #10.