Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (anonymous):

How can I make my program in C detect an input of the arrow keys? And how can I put it in conditional statements like if( up arrow key ...) Does the arrow keys have ascii values?

OpenStudy (anonymous):

Ah in this , go search for the ASCII code of the up arrow key, then use the ASCII code to implement your program.

OpenStudy (anonymous):

Look here : http://graphemica.com/

OpenStudy (anonymous):

I does not search

OpenStudy (anonymous):

I send you that page , it has some information.

OpenStudy (anonymous):

is it 37 38 39 40 for the left up right down arrow keys?

OpenStudy (anonymous):

As I found here : http://chexed.com/ComputerTips/asciicodes.php they are as follow : 24 ↑ Up arrow 25 ↓ Down arrow 26 → Right arro 27 ← Left arrow

OpenStudy (anonymous):

For console applications anyway

OpenStudy (anonymous):

what are ncurses?

OpenStudy (anonymous):

#include<iostream> using namespace std; #include <stdio.h> #include <conio.h> #include <dos.h> #include <windows.h> void gotoxy(int xpos, int ypos) { COORD scrn; HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE); scrn.X = xpos; scrn.Y = ypos; SetConsoleCursorPosition(hOuput,scrn); } int main (void) { int row=0,col=0; cout<<"press any Arrow key or enter: "; while(1) { if(kbhit()) { char c = getch(); if(c==-32) { c = getch(); if(c==80) // Downward { cout<<"Downward"; } else if(c==75) // Left { cout<<"Left"; } else if(c==77) // Up { cout<<"Right"; } else if(c== 72) // Right { cout<<"Up"; } } else if(c==13) { cout<<"Enter"; } else if(c==32) { cout<<"Space"; } else { cout<<c; } row++; gotoxy(0+col,row+0); cout<<"press any Arrow key or enter: "; } } return 0; }

OpenStudy (anonymous):

This is in c++.Just do a small change to transfer it into C and then run,you will get your answer.Or simply run as c++ project

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!