Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ALT key

Status
Not open for further replies.

qbasicking

Programmer
Aug 19, 2001
628
US
i'm having a problem working with the ALT key (Ctrl, Shift, et cetera also). I am probably just doing one little dumb thing wrong, I know this doesn't look right but I just can't put my fingure on what is wrong. Here is a sample of the source code I am using:

KEY 15, CHR$(0), CHR$(&H56) 'declaring key
KEY(15) ON
DO
ON KEY(15) GOSUB aa
x$ = INKEY$ 'this is just so i can get out of the loop
LOOP UNTIL x$ = CHR$(27) 'ESC key
END
aa: PRINT "ALT"
END

I think there is something wrong with the way I declare the key. I also can't get any other keys to work in this way. (Ctrl, Alt, Bckspace, Del, Enter, Tab, End, Home, PgUp, PgDn) don't worry about the arrow keys i use a different type of code to work them.
 
Hi,

I think your problem is that the first line should read

Key 15,chr$(0)+chr$(&H38) (Which is the scan code for ALT.

Try this program below to demonstrate the KEY n command:

CLS
WHILE 1 = 1

KEY 15, CHR$(&H0) + CHR$(&H38) 'Just the ALT Key
KEY 16, CHR$(&H40) + CHR$(&H38) 'Alt Key With Caps Lock ON
KEY 17, CHR$(&H0) + CHR$(&H36) 'Just the Right Shift

KEY(15) ON
KEY(16) ON
KEY(17) ON

ON KEY(15) GOSUB alt 'ALT Key pressed (Caps lock off)
ON KEY(16) GOSUB alt2 'ALT Key Pressed (Caps Lock On)
ON KEY(17) GOSUB Rshift 'Right Shift pressed (Caps Lock Off)

WEND

alt:
PRINT "Alt"
RETURN

alt2:
PRINT "Alt + Caps Lock"
RETURN

Rshift:
PRINT "Right Shift"
RETURN


Please note there is no exit key just press CTRL & BREAK to stop program execution.

Hope this helps.

Regards
 
sry - i did have 38 in there. I realized what the problem was myself. I didn't realize that the NUM Lock automatically turns on, so i had to put its code in. It works fine now. thanx anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top