#### Archived

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

# Arrow Keys+scan code= !@\$%

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

## Recommended Posts

Gander at this first: #define RtArrw 0x4d #define LftArrw 0x4b #define UpArrw 0x48 #define DnArrw 0x50 ... //Movement switch(getch()){ case LftArrw:{...} case UpArrw:{...} case RtArrw:{...} case DnArrw:{...} }; Now when I do this, the arrow keys dont work, but I J L & M do. I''d really really really like to know whats going on, and how to get them to work for my RPG.

##### Share on other sites
With an arrow key there will be two getch''s sent. The first will be a zero and then the keycode. For example:
  switch(getch()) { case 0: switch(getch()) { case LEFT: // ... break; // ... } break;}

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
I remember learning this in Pascal at college!
Like the above post says you have to read the keypress twice because arrow key, function key etc use extended scan code...the first code will just be a zero so you have to call getch() straight after the first one to actually get the scan code.

In Pascal (like you ever wanted to know!) it''s:

var ch : char;

begin

case ch of...
...
end;

end;

I just felt like putting that in!

Steve

---------------------
Light of my life
Fire of my loins.
My sin, my soul
LOLITA
---------------------

##### Share on other sites
Why do you keep starting new threads for the same question continued (this is your third I believe)? It''s rude.

• 10
• 17
• 9
• 13
• 41