12-04-2022, 12:19 AM
Interestingly enough, INKEY won't pick up the + or minus key when ctrl is held....
Pete
Code: (Select All)
_CONTROLCHR OFF
DO
_LIMIT 30
DEF SEG = 0
IF PEEK(1047) MOD 16 = 1 OR PEEK(1047) MOD 16 = 2 THEN
KeyCombos = 1 ' Shift
ELSEIF PEEK(1047) MOD 16 = 3 OR PEEK(1047) MOD 16 = 4 THEN
KeyCombos = 2 ' Ctrl
ELSEIF PEEK(1047) MOD 16 = 5 OR PEEK(1047) MOD 16 = 6 THEN
KeyCombos = 3 ' Ctrl+Shift
ELSEIF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
KeyCombos = 4 ' Alt
ELSEIF PEEK(1047) MOD 16 = 9 OR PEEK(1047) MOD 16 = 10 THEN
KeyCombos = 5 ' Shift+Alt
ELSEIF PEEK(1047) MOD 16 = 12 THEN
KeyCombos = 6 ' Ctrl+Alt
ELSEIF PEEK(1047) MOD 16 = 14 THEN
KeyCombos = 7 ' Shift+Ctrl+Alt
ELSE
KeyCombos = 0
END IF
DEF SEG
mykey$ = INKEY$
IF LEN(mykey$) OR KeyCombos THEN
SELECT CASE mykey$
CASE CHR$(27)
PRINT " INKEY$ CODE: CHR$(27)"
EXIT DO ' Escape loop to end program snippet.
END SELECT
show_Values mykey$, KeyCombos
END IF
LOOP
SUB show_Values (mykey$, KeyCombos)
STATIC OldKeyCombos
IF KeyCombos = OldKeyCombos AND LEN(mykey$) = 0 THEN EXIT SUB ' Neat trick to only print once to screen while PEEK discovered keys are held down.
DO ' Falx loop to avoid printing INKEY printing if only a non-INKEY$ is held down.
SELECT CASE LEN(mykey$)
CASE 0
EXIT DO
CASE 1
b = ASC(mykey$) ' ASC() converts a string character to a numeric value.
a$ = ""
CASE 2
b = ASC(MID$(mykey$, 2, 1))
a$ = "CHR$(0)" ' This is the nul character INKEY$ reports for 2 byte length key representation like the F1 - F12 keys.
END SELECT
b$ = LTRIM$(STR$(b)) ' This is how you convert a numeric variable to a string variable.
PRINT " INKEY$ CODE: ";
IF LEN(a$) THEN PRINT a$; " + ";
PRINT "CHR$("; b$; ") "; "AKA: " + CHR$(34) + CHR$(b) + CHR$(34) + " ";
EXIT DO
LOOP
IF KeyCombos THEN
SELECT CASE KeyCombos
CASE 1
PRINT " Shift Down";
CASE 2
PRINT " Crtl Down";
CASE 3
PRINT " Shift + Ctrl Down";
CASE 4
PRINT " Alt Down";
CASE 5
PRINT " Shift + Alt Down";
CASE 6
PRINT " Ctrl + Alt Down";
CASE 7
PRINT " Shift + Ctrl + Alt Down";
END SELECT
OldKeyCombos = KeyCombos
END IF
PRINT
END SUB
Pete
If eggs are brain food, Biden takes his scrambled.