LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2009, 06:29 PM   #1
CoderMan
Member
 
Registered: Jan 2009
Location: Gemini Capsule 25164
Distribution: Gentoo
Posts: 375
Blog Entries: 24

Rep: Reputation: 43
Question 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).
 
Old 02-16-2009, 08:17 PM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: FreeBSD,Debian wheezy
Posts: 811

Rep: Reputation: 179Reputation: 179
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling Control Characters in Linux. bala.linux Linux - General 3 03-27-2008 01:28 PM
LXer: OOXML's (Out of) Control Characters LXer Syndicated Linux News 0 03-25-2008 04:50 PM
How do I generate ASCII control characters from they keyboard? Mahonri Linux - General 2 09-20-2007 08:32 AM
[SOLVED] control characters in vi procfs Linux - Newbie 4 08-30-2007 10:52 PM
Viewing control characters in a text file dmorse Linux - General 2 01-06-2007 11:10 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration