Basic and Advance C Question:

How do I read the arrow keys? What about function keys?

Tweet Share WhatsApp

Answer:

Terminfo, some versions of termcap, and some versions of curses have support for these non-ASCII keys. Typically, a special key sends a multicharacter sequence (usually beginning with ESC, '33'); parsing these can be tricky. (curses will do the parsing for you, if you call keypad first.)
Under MS-DOS, if you receive a character with value 0 (not '0'!) while reading the keyboard, it's a flag indicating that the next character read will be a code indicating a special key. See any DOS programming guide for lists of keyboard scan codes. (Very briefly: the up, left, right, and down arrow keys are 72, 75, 77, and 80, and the function keys are 59 through 68.)

Download C Programming PDF Read All 221 C Programming Questions
Previous QuestionNext Question
How can I do serial comm port I O?How can I make it pause before closing the program output window?