• Advertisement

Archived

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

Scan Codes wont' work

This topic is 5908 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m tryin to get the arrow keys to work for my RPG, and when i use the scan codes for them, it ends up using the I,L,J and M keys instead. any help on this one?

Share this post


Link to post
Share on other sites
Advertisement
i''m trying to use the scan codes like this:

#define RtArrw 0x4d
#define LfArrw 0x4b
#define UpArrw 0x48
#define DnArrw 0x50

...

if (kbhit() == RtArrw)
...etc.

i''m assuming there is another way to use hex codes, but dont know too much about C++ yet.

Share this post


Link to post
Share on other sites
quote:
Original post by Rogue Dragon
if (kbhit() == RtArrw)

It would behove you to peruse the documentation pertaining to kbhit(). It is specified as returning a non-zero value if the keyboard has been hit, and explicitly suggests the use of getch() or getche() to acquire the actual key:
...
if(kbhit())
{
switch(getch()) // get character without echoing to console
{
case UpArrw:
// do up arrow stuff
break;
case RtArrw:
// do right arrow stuff
break;
case DnArrw:
// ...and so on
default:
// stuff to do if/when key hit is none of the arrow keys
break;
}
}
...

quote:
i''m assuming there is another way to use hex codes, but dont know too much about C++ yet.

Has nothing to do with C++ per se. kbhit() is a standard C library function for the DOS/Windows platform.

Share this post


Link to post
Share on other sites

  • Advertisement