Getting Key Codes
Posted: Mon Mar 20, 2006 11:47 am
Hi, I most of the key codes, and i was wondering what the key codes for Ctrl+Left and Ctrl+Left, and how do people get them
Discuss QBasic, Freebasic, QB64 and more
http://petesqbsite.com/phpBB3/
Code: Select all
Do
k$=inkey$
Loop until len(k$)
Code: Select all
if len(k$)>1 then special char. code else regular char code
Code: Select all
Num=asc(right$(k$,1))
Code: Select all
DECLARE SUB Center (y%, T$)
DECLARE SUB Delay (Amt!)
SCREEN 0
COLOR 9, 1
CLS
COLOR 14
Center 3, "K e y F i n d e r 0 . 5"
COLOR 8
Center 4, "?????????????????????????????"
COLOR 7
Center 6, " This portion of the program will display the ASCII character"
Center 7, " codes for the keys you press on the keyboard. Extended keys"
Center 8, " contain TWO characters, so both will displayed. Combination"
Center 9, " keys like [Ctrl]+[S] will display as extended, if they are. "
Center 10, " Press the [Esc] key, (or Ctrl + [ ), to quit at anytime."
COLOR 9, 1
Center 12, "??????????????????????????????????????????????????????????"
Center 13, "? ? ? ?"
Center 14, "???????????????????????????????????????????????????????????"
Center 15, "??????????????????????????????????????????????????????????"
Center 16, "? ? ? ?"
Center 17, "???????????????????????????????????????????????????????????"
COLOR 11
LOCATE 13, 13: PRINT "Primary ASCII Code"
LOCATE 13, 34: PRINT "Secondary ASCII Code"
LOCATE 13, 57: PRINT "Key Pressed"
COLOR 15
DO
a$ = INKEY$
IF a$ <> "" THEN
LOCATE 16, 19: PRINT " "
LOCATE 16, 40: PRINT " "
LOCATE 16, 57: PRINT " "
IF LEN(a$) > 1 THEN
b$ = STR$(ASC(LEFT$(a$, 1)))
c$ = STR$(ASC(RIGHT$(a$, 1)))
LOCATE 16, 22: PRINT "0"
LOCATE 16, 42: PRINT c$
LOCATE 16, 57: PRINT "CHR$(0)+"; CHR$(34); LTRIM$(RIGHT$(a$, 1)); CHR$(34);
ELSE
b$ = STR$(ASC(a$))
i% = 0
IF a$ = CHR$(9) THEN i% = 1
IF a$ = CHR$(13) THEN a$ = " "
'IF a$ = CHR$(8) THEN a$ = "BkSpc": i% = 2
LOCATE 16, 20: PRINT b$
LOCATE 16, 43: PRINT "--"
LOCATE 16, 61 - i%: PRINT CHR$(34); a$; CHR$(34)
END IF
IF a$ = CHR$(27) THEN EXIT DO
END IF
LOOP
Part2:
COLOR 7
Center 6, " This portion of the program will display the computer key- "
Center 7, " board scan codes. Press a key or key combination, and the "
Center 8, " information will be displayed below. Note that the codes "
Center 9, " are different for similar keys that are placed differently. "
Center 10, " Press the [Esc] key, (or Ctrl + [ ), to quit at anytime."
COLOR 9, 1
Center 12, "??????????????????????????????????????????????????????????"
Center 13, "? ? ?"
Center 14, "???????????????????????????????????????????????????????????"
Center 15, "??????????????????????????????????????????????????????????"
Center 16, "? ? ?"
Center 17, "???????????????????????????????????????????????????????????"
COLOR 11
LOCATE 13, 17: PRINT "Keyboard Scan Code"
LOCATE 13, 49: PRINT "Key Pressed"
COLOR 15
old% = INP(96)
DO
a% = INP(96)
LOCATE 16, 23: PRINT a%; " "
Delay .05
a$ = INKEY$
IF a$ = CHR$(27) THEN EXIT DO
LOOP
SUB Center (y%, T$)
i% = 40 - INT(.5 * LEN(T$))
IF i% < 1 THEN i% = 1
LOCATE y%, i%, 0
PRINT T$;
END SUB
SUB Delay (Amt!)
T! = TIMER + Amt!
WHILE TIMER < T!
WEND
END SUB