# Qbasic games Arrow keys!!!

I need help with how to make the arrowkeys work in qbasic...For exmple if I want a little box to move....how do I do ==???

• The best method of getting the arrow keys is to use \$INKEY. You can

trap input with INKEY in the following manner:

1 Varia\$ = \$Inkey: if Varia\$ = "" then goto 1

You next need to look up the keyboard scan codes

for the arrow keys. You can find a listing of keyboard

here are the ones for the arrow keys:

72 Up 77 Right

75 Left 80 Down

\$INKEY returns the keyboard scan code with a null

character in front of it, so you have to check for it

in the following manner

if Varia\$ = Chr\$(0) + Chr\$(72) then GoUp

• DO

q\$ = INKEY\$

IF q\$ = CHR\$(0) + "K" THEN

IF q\$ = CHR\$(0) + "M" THEN

IF q\$ = CHR\$(0) + "H" THEN

IF q\$ = CHR\$(0) + "P" THEN

LOOP

The arrow keys return 2 bytes. The first is CHR\$(0), and the second corresponds to the above letters (CAPITAL). I don't recall which letter is which arrow, but it should be easy enough to figure out.

Hope this helps!

Ciao

• DO

q\$ = INKEY\$

IF q\$ = CHR\$(0) + "K" THEN - what to do here

IF q\$ = CHR\$(0) + "M" THEN - what to do here

IF q\$ = CHR\$(0) + "H" THEN - what to do here

IF q\$ = CHR\$(0) + "P" THEN - what to do here

LOOP

The arrow keys return 2 bytes. The first is CHR\$(0), and the second corresponds to the above letters (CAPITAL). I don't recall which letter is which arrow, but it should be easy enough to figure out.

Hope this helps!

Ciao