Method: Curses.getch

Defined in:
ext/curses/curses.c

.getchObject

Read and returns a character from the window.

See Curses::Key to all the function KEY_* available



859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
# File 'ext/curses/curses.c', line 859

static VALUE
curses_getch(VALUE obj)
{
    int c;

    curses_stdscr();
    rb_thread_call_without_gvl(getch_func, &c, RUBY_UBF_IO, 0);
    if (c == EOF) return Qnil;
    if (rb_isprint(c)) {
	char ch = (char)c;

	return rb_external_str_new_with_enc(&ch, 1, keyboard_encoding);
    }
    return UINT2NUM(c);
}