Welcome to Pete's QBASIC Site!


FreeBasic Top 50

QB Top 50

QB FAQ
How do I use the arrow keys in QBasic?

There are two different ways to use ther arrow keys, and I'll show you both of them.

First Method:


DO
A$ = INKEY$ 'Get Key
IF A$ = CHR$(0) CHR$(72) THEN PRINT "You pressed up!"
IF A$ = CHR$(0) CHR$(80) THEN PRINT "You pressed down!"
IF A$ = CHR$(0) CHR$(75) THEN PRINT "You pressed left!"
IF A$ = CHR$(0) CHR$(77) THEN PRINT "You pressed right!"
IF A$ = CHR$(27) THEN END '<---ESC button
LOOP



Second Method:

DO
kbd$ = INKEY$ 'Get Key
IF kbd$ <> "" THEN
SELECT CASE kbd$ 'Select what button you hit
CASE CHR$(0) "H"
PRINT "Up"
CASE CHR$(0) "P"
PRINT "Down"
CASE CHR$(0) "K"
PRINT "Left"
CASE CHR$(0) "M"
PRINT "Right"
CASE CHR$(13)
PRINT "You hit Enter"
CASE CHR$(27)
END
END SELECT
END IF
LOOP


(This short tutorial was originally written by Necrolyte.)

Submitted by: Pete on June 22, 2004

Return to the FAQ


Copyright Pete's QBASIC / QuickBasic Site, 1998-2013.
All rights reserved. Site owned and operated by Pete Berg. Programs and submitted content are property of their creators, and appear on this site by direct or implied permission. Pete's QBasic Site is powered by Coranto. This site was created entirely in Notepad.