LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   control characters in C (https://www.linuxquestions.org/questions/programming-9/control-characters-in-c-705192/)

CoderMan 02-16-2009 06:29 PM

control characters in C
 
Hi. I'm working on my ncurses application, written in C. I get user input through a loop which uses getchar(). I was able to recognize Ctrl-n by comparing the keypress to ASCII character 16, and this seems to work fine.

However, if I noticed that the ASCII character for Ctrl-j (10) is the same as the Line Feed. I tested this, and if I press enter on the keyboard I get the same ASCII value as when I press Ctrl-j.

So, what do I do if I want Ctrl-j to mean something different in my program than pressing enter?

The ncurses terminal mode is set to raw, with a 100 millisecond timeout, and keypad is on (I'm already using the up and down arrow-keys).

wje_lq 02-16-2009 08:17 PM

Quote:

what do I do if I want Ctrl-j to mean something different in my program than pressing enter?
If you're using ncurses, you need a different (i.e., wildly nonstandard) keyboard, or load your keyboard with a different set of characters somehow, of which I'm completely ignorant.

Unless you're willing to get raw keycodes (not raw characters, as you're getting now), ^J and <Enter> (or however that key is labeled on your keyboard) yield the same value exactly.


All times are GMT -5. The time now is 05:19 PM.