# Control characters in ruby

**URL:** <https://rubytalk.org/t/control-characters-in-ruby/62479>\
**Category:** ruby-talk\
**Created:** [20 April 2011 10:57 UTC](https://rubytalk.org/t/control-characters-in-ruby/62479 "2011-04-20T10:57:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arun\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Arun\_Kumar](https://rubytalk.org/u/Arun_Kumar)\
**Post date:** [20 April 2011 10:57 UTC](https://rubytalk.org/t/control-characters-in-ruby/62479/1 "2011-04-20T10:57:00Z")

</div>

Hello all,  
&nbsp;&nbsp;&nbsp;&nbsp;I wanted to know how to accept control characters such as ESC, F1,  
F2 from a command line in Ruby. I'm working on Opensuse (11.1) Linux.

> **···**
>
> --  
> Cheers & Regards,  
> Arun Kumar M S  
> Systems Engineer,  
> AVK systems,  
> IIIT-B campus,  
> Electronic city,  
> Bangalore  
> [www.avksystems.com](http://www.avksystems.com)

---

<div class="post-metadata">

**Author:** ![Urabe\_Shyouhei1](https://avatars.discourse-cdn.com/v4/letter/u/6a8cbe/32.png) [@Urabe\_Shyouhei1](https://rubytalk.org/u/Urabe_Shyouhei1)\
**Post date:** [20 April 2011 11:29 UTC](https://rubytalk.org/t/control-characters-in-ruby/62479/2 "2011-04-20T11:29:53Z")

</div>

(04/20/2011 07:57 PM), Arun Kumar wrote:

> Hello all,  
> &nbsp;&nbsp;&nbsp;&nbsp;I wanted to know how to accept control characters such as ESC, F1,  
> F2 from a command line in Ruby. I'm working on Opensuse (11.1) Linux.

[http://c-faq.com/osdep/cbreak.html](http://c-faq.com/osdep/cbreak.html)

(hint: Ruby is written in C)

---

<div class="post-metadata">

**Author:** ![Arun\_Kumar](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Arun\_Kumar](https://rubytalk.org/u/Arun_Kumar)\
**Post date:** [20 April 2011 17:40 UTC](https://rubytalk.org/t/control-characters-in-ruby/62479/3 "2011-04-20T17:40:19Z")

</div>

Thank you so much. The solution for my case lies in ncurses or related  
libraries (rbcurse, ffi-ncurses)...

> **···**
>
> On Wed, Apr 20, 2011 at 4:59 PM, Urabe Shyouhei \<shyouhei@ruby-lang.org\> wrote:
> 
> > (04/20/2011 07:57 PM), Arun Kumar wrote:
> > 
> > > Hello all,  
> > > I wanted to know how to accept control characters such as ESC, F1,  
> > > F2 from a command line in Ruby. I'm working on Opensuse (11.1) Linux.
> > 
> > [Question 19.1](http://c-faq.com/osdep/cbreak.html)
> > 
> > (hint: Ruby is written in C)
> 
> --  
> Cheers & Regards,  
> Arun Kumar M S  
> Systems Engineer,  
> AVK systems,  
> IIIT-B campus,  
> Electronic city,  
> Bangalore  
> [www.avksystems.com](http://www.avksystems.com)

---

<div class="post-metadata">

**Author:** ![Urabe\_Shyouhei1](https://avatars.discourse-cdn.com/v4/letter/u/6a8cbe/32.png) [@Urabe\_Shyouhei1](https://rubytalk.org/u/Urabe_Shyouhei1)\
**Post date:** [20 April 2011 22:17 UTC](https://rubytalk.org/t/control-characters-in-ruby/62479/4 "2011-04-20T22:17:25Z")

</div>

(04/21/2011 02:40 AM), Arun Kumar wrote:

> Thank you so much. The solution for my case lies in ncurses or related  
> libraries (rbcurse, ffi-ncurses)...

FYI ruby has standard library support for curses. I don't know if Suse ships  
their ruby with that feature compiled in but I'm sure they have it somewhere  
in their package system.
