Subject: Keypressed in Ruby
	Date: Fri 23 Nov 12 01:08:33PM +0900

Quoting Kamil G. (lists / ruby-forum.com):

> i tried to do it using Curses but getch function is waiting everytime
> for
> key and i don't want that. I want program to work independently from key
> pressing unless the right key is pressed. Any tips for me?

With Curses, you have to set the terminal in Cbreak mode, otherwise
you will get data only when a carriage return is pressed. This is
obtained by calling

Curses::cbreak

Then, you may also want getch to be non-blocking. In Curses, this is a
per-window setting - see

ri Curses::Window#nodelay=

To set non-blocking getch for your main window, the instruction to use
is

Curses::stdscr.nodelay=true

Remember to close the screen before exiting the program, with

Curses::close_screen

Hope this helps

Carlo

-- 
  *         Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido / fluido.as             che bisogno ci sarebbe
  *               di parlare tanto di amore e di rettitudine? (Chuang-Tzu)