Hey all! This looks like a great board. kudos on being one of the more lively QB communities.
My question is, how do you trap the cursor keys for use with the KEY (N) statement? I've found out how to do the Numeric Keypad arrow keys, like 8/up and 6/right, etc. But is there any way to do this with the cursor keys themselves?
My guess would be this:
KEY 15, CHR$(0) + CHR$(35)
KEY 15 ON
10
ON KEY(15) Gosub UpArrow
GOTO 10
UpArrow:
print "UP"
end
However, this doesn't work. I used 35 for the letter H, because when you do an inkey$ loop, I've always seen the up arrow key used like this:
if inkey$ = chr$(0) + "H" then Gosub UpArrow.
So I figured this would also work with KEY statements, but no dice. Anyone have any suggestions?
Thanks in advance,
Stevo
Using the arrow keys with Key On?
Moderators:Administrator, Global Moderator
You can get the list of Key scan code here...
http://www.qbasicnews.com/qboho/qckadvr.kbsct.shtml
Hope it helps...
http://www.qbasicnews.com/qboho/qckadvr.kbsct.shtml
Hope it helps...
Define keys
This works for me:
' keyboard definitions
KEY 15, CHR$(0) + CHR$(1) ' Define ESC key
KEY 18, CHR$(128) + CHR$(72) ' Define uparrow
KEY 19, CHR$(128) + CHR$(80) ' Define downarrow
KEY 20, CHR$(128) + CHR$(77) ' Define rightarrow
KEY 21, CHR$(128) + CHR$(75) ' Define leftarrow
' keyboard definitions
KEY 15, CHR$(0) + CHR$(1) ' Define ESC key
KEY 18, CHR$(128) + CHR$(72) ' Define uparrow
KEY 19, CHR$(128) + CHR$(80) ' Define downarrow
KEY 20, CHR$(128) + CHR$(77) ' Define rightarrow
KEY 21, CHR$(128) + CHR$(75) ' Define leftarrow