Skip to main content
gamedev.net
🔒 Locked

Arrow Keys+scan code= !@$%

Started by Rogue Dragon 2 replies 250+ views
Original Post
Rogue Dragon
Rogue Dragon
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.
yottskry
yottskry
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
ch:=readkey;
ch:=readkey;

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
---------------------
"All the girls that turn me on (turn me down)"
Oluseyi
Oluseyi
Why do you keep starting new threads for the same question continued (this is your third I believe)? It''s rude.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.