• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Using the arrow keys in a console program

## Recommended Posts

ANTZelda56    122
How can you get input from the arrow keys in a console/DOS program? Each key returns -32 from getch()... so I''m in the dark.

##### Share on other sites
Guest Anonymous Poster
I did this a long time ago, so I am not sure if this will work or if it is right

int c = getch();if(c <= 0) c = getch() + 0x100;switch(c) {case 333 :}Not sure of the 333 number. Probably might be something else.

##### Share on other sites
Guest Anonymous Poster
I did this a long time ago, so I am not sure if this will work or if it is right

int c = getch();if(c <= 0) c = getch() + 0x100;switch(c) {case 333 :}

Not sure of the 333 number. Probably might be something else.

##### Share on other sites
ANTZelda56    122
The problem is, I need to tell the diffrence from up, down, left and right.

##### Share on other sites
Oluseyi    2103
#include <windows.h>GetAyncKeyState(VK_UP); // VK_DOWN, VK_LEFT, VK_RIGHT

[Edit: VK_DOWN, not VL_DOWN]

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

[edited by - Oluseyi on March 17, 2002 10:33:32 PM]