# Tab and arrow-keys in gets

**URL:** <https://www.ruby-forum.com/t/tab-and-arrow-keys-in-gets/86260>\
**Category:** Ruby\
**Created:** [February 21, 2007, 12:17am UTC](https://www.ruby-forum.com/t/tab-and-arrow-keys-in-gets/86260 "2007-02-21T00:17:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![judofyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/90ced4/32.png) [@judofyr](https://www.ruby-forum.com/u/judofyr)\
**Post date:** [February 21, 2007, 12:17am UTC](https://www.ruby-forum.com/t/tab-and-arrow-keys-in-gets/86260/1 "2007-02-21T00:17:24Z")

</div>

Hi!

I’m making a simple Ruby shell. It’s all basing on an endless  
while-loop and $stdin.gets. But here (on my Linux box) I cannot use  
the arrow key. It just shows: “^[[A”. And it would be great too have a  
tab-feature.

But how do you implement these features?

---

<div class="post-metadata">

**Author:** ![judofyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/90ced4/32.png) [@judofyr](https://www.ruby-forum.com/u/judofyr)\
**Post date:** [February 21, 2007, 2:13am UTC](https://www.ruby-forum.com/t/tab-and-arrow-keys-in-gets/86260/2 "2007-02-21T02:13:32Z")

</div>

On 2/21/07, Magnus H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi!
> 
> I’m making a simple Ruby shell. It’s all basing on an endless  
> while-loop and $stdin.gets. But here (on my Linux box) I cannot use  
> the arrow key. It just shows: “^[[A”. And it would be great too have a  
> tab-feature.
> 
> But how do you implement these features?

require ‘readline’

while line = Readline.readline('foo\> ', true)  
puts “You gave me: #{line}”  
end

Have fun 🙂

Some (very) basic docs are at:  
[http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/readline/README?view=markup](http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/readline/README?view=markup)
