Alcamtar
Alcamtar

Reputation: 1582

How to return Ctrl+M from ncurses getch()?

I am writing an application using ncurses and trying to get a CTRL-M keypress from the keyboard. Ncurses is returning CTRL-J (aka \n) whenever I press CTRL-M (aka \r), so I suspect somewhere it is doing a CRLF translation. My program is running in raw() mode so I don't think it should be doing any translation. Is this an ncurses problem or is it coming from somewhere upstrea, like the terminal driver?

How can I get it to give me raw key presses without translation?

FWIW I am using ncurses on Linux, running bash in xfce4-terminal. My TERM is xterm-256color. I've searched on Google and checked the ncurses docs but can't find anything on this issue.

Upvotes: 0

Views: 230

Answers (1)

rici
rici

Reputation: 241671

You need to call nonl(). Although it is documented in the outopts manual section, it affects input as well.

Upvotes: 1

Related Questions