01-05-2026, 09:16 PM (This post was last modified: 01-06-2026, 03:14 AM by Pete.)
So we press F1. Ever just wanted to see F1 displayed instead of: Chr$(0) + ;
Well now you can. Hey it was either that or buy you guys a Popeil Pocket Fisherman for X-mas.
Anyway, it works with the key combos available in INKEY$, too. The guts can are good for conversion uses, which funnily enough I had one of those that I backward engineered to make this demo.
Edit: Forum messed up some ascii characters, so I redid it using the QB64 IDE Export feature and that failed miserably, too.
So if only we had a forum that wouldn't MUCK UP a perfectly good code block without switching ascii characters like turning F's into M's... Oh wait, we do!
PS I'll add a zip file later; right now I'm too kissed, opay?
Edit: Zip added. Two files. One with string characters, and one with string 'numbers'.
Now two issues, What sucks about GLUT is Ctrl + J and Ctrl + Enter both return Chr$(10) with Inkey, and if I used _KeyHit both would return Chr$(13). So when we press Ctrl + Enter its going to display Ctrl + J. Also, both Inkey$ and _KeyHit return like values for Ctrl + Delete and Ctrl + Backspace, so we have a key duplication error there as well. Everything else should display correctly, if not, it's a bug... I mean a feature!
01-05-2026, 09:25 PM (This post was last modified: 01-05-2026, 09:30 PM by bplus.)
The report output is not matching the keys I am pressing. I assume it is supposed to?
Nothing for enter, arrows ok but what's the W?
home, end, pgup and pgdn all mixed up?
do you want more? F12 is 2 ins, F1 - F10 look 0K. F11 is blank f1
Well I'd like to eventually get one that will post without any problems on this forum, so I haven't added numlock to this routine, but before I do, let's test it out...
Code: (Select All)
Do
_Limit 30
b$ = InKey$
If _KeyDown(100303) Or _KeyDown(100304) Then shift = -1 Else If shift Then shift = 0
If _KeyDown(100305) Or _KeyDown(100306) Then ctrl = -1 Else If ctrl Then ctrl = 0
If _KeyDown(100307) Or _KeyDown(100308) Then alt = -1 Else If alt Then alt = 0
If Len(b$) Then
Sound 1000, .2
If alt Then
Restore AltKeys
ElseIf ctrl Then Restore CtrlKeys
ElseIf shift Then Restore UcaseKeys Else Restore LcaseKeys
End If
If Len(b$) = 1 Then e = Asc(b$): seed = 22 Else e = Asc(Mid$(b$, 2, 1)): seed = 0
i = 0
Do
i = i + 1
Read a, key$
If key$ = "eof" Then Exit Do
If a = e And i > seed Then
If shift Then
j = InStr("`1234567890-=[]\;',./", key$)
If j Then key$ = Mid$("~!@#$%^&*()_+{}|:'<>?", j, 1): If key$ = "'" Then key$ = Chr$(34)
End If
If key$ = "-Q" Then key$ = Chr$(34) ' Compensate for inability to store a quote mark in a data statement.
If shift + ctrl + alt Then If Len(key$) = 1 Then key$ = UCase$(key$)
If shift Then Print "Shift ";
If ctrl Then Print "Ctrl "; Rem If key$ = "J" Then key$ = "Enter" GLUT error. BTW _Keyhit would return 13 for Ctrl + Enter or Ctrl + J.
If alt Then Print "Alt ";
Print key$: Exit Do
End If
Loop
End If
Loop
UcaseKeys:
Data 84,F1,85,F2,86,F3,87,F4,88,F5,89,F6,90,F7,91,F8,92,F9,93,F10,133,F11,134,F12,82,Insert,83,Delete,73,PgUp,81,PgDn,71,Home,79,End,75,Arrow Lt,72,Arrow Up,80,Arrow Dn,77,Arrow Rt,8,Backspace,126,~,33,!,64,@,35,#,36,$,37,%,94,^,38,&,42,*,40,(,41,),95,_,43,+,81,Q,87,W,69,E,82,R,84,T,89,Y,85,U,73,I,79,O,80,P,123,{,125,},124,|,65,A,83,S,68,D,70,F,71,G,72,H,74,J,75,K,76,L,58,":",34,-Q,90,Z,88,X,67,C,86,V,66,B,78,N,77,M,60,<,62,>,63,?,32,Space,15,Tab,27,Esc,13,Enter,-1,eof
LcaseKeys:
Data 59,F1,60,F2,61,F3,62,F4,63,F5,64,F6,65,F7,66,F8,67,F9,68,F10,133,F11,134,F12,82,Insert,83,Delete,73,PgUp,81,PgDn,71,Home,79,End,75,Arrow Lt,72,Arrow Up,80,Arrow Dn,77,Arrow Rt,8,Backspace,96,`,49,1,50,2,51,3,52,4,53,5,54,6,55,7,56,8,57,9,48,0,45,-,61,=,113,q,119,w,101,e,114,r,116,t,121,y,117,u,105,i,111,o,112,p,91,[,93,],92,\,97,a,115,s,100,d,102,f,103,g,104,h,106,j,107,k,108,l,59,;,39,',122,z,120,x,99,c,118,v,98,b,110,n,109,m,44,",",46,.,47,/,32,Space,9,Tab,27,Esc,13,Enter,-1,eof
CtrlKeys:
Data 94,F1,95,F2,96,F3,97,F4,98,F5,99,F6,100,F7,101,F8,102,F9,103,F10,137,F11,138,F12,146,Insert,147,Delete,132,PgDp,118,PgDn,119,Home,117,End,115,Arrow Lt,141,Arrow Up,145,Arrow Dn,116,Arrow Rt,147,Backspace,17,q,23,w,5,e,18,r,20,t,25,y,21,u,9,i,15,o,16,p,1,a,19,s,4,d,6,f,7,g,8,h,10,j,11,k,12,l,26,z,24,x,3,c,22,v,2,b,14,n,13,m,32,Space,0,2,30,6,31,-,-1,eof
AltKeys:
Data 104,F1,105,F2,106,F3,108,F5,109,F6,110,F7,111,F8,112,F9,113,F10,139,F11,140,F12,162,Insert,163,Delete,153,PgDp,161,PgDn,151,Home,159,End,155,Arrow Lt,152,Arrow Up,160,Arrow Dn,157,Arrow Rt,14,Backspace,41,`,120,1,121,2,122,3,123,4,124,5,125,6,126,7,127,8,128,9,129,0,130,-,131,=,16,q,17,w,18,e,19,r,20,t,21,y,22,u,23,i,24,o,25,p,26,[,27,],43,\,30,a,31,s,32,d,33,f,34,g,35,h,36,j,37,k,38,l,39,;,40,',44,z,45,x,46,c,47,v,48,b,49,n,50,m,51,",",52,.,53,/,-1,eof
I also discovered Ctrl + Shift with then numbers 2, 6, and - key return values!
Pete
PS Rho should like this one, it's DATA lists... YUCK!
01-07-2026, 03:57 AM (This post was last modified: 01-07-2026, 03:57 AM by Pete.)
Okay, that one worked. Let's try a string type now...
Code: (Select All)
UcaseKeys$ = ",84 F1,85 F2,86 F3,87 F4,88 F5,89 F6,90 F7,91 F8,92 F9,93 F10,133 F11,134 F12,82 Insert,83 Delete,73 PgUp,81 PgDn,71 Home,79 End,75 Arrow Lt,72 Arrow Up,80 Arrow Dn,77 Arrow Rt,8 Backspace,126 ~,33 !,64 @,35 #,36 $,37 %,94 ^,38 &,42 *,40 (,41 ),95 _,43 +,81 Q,87 W,69 E,82 R,84 T,89 Y,85 U,73 I,79 O,80 P,123 {,125 },124 |,65 A,83 S,68 D,70 F,71 G,72 H,74 J,75 K,76 L,58 :,34 -Q,90 Z,88 X,67 C,86 V,66 B,78 N,77 M,60 <,62 >,63 ?,32 Space,15 Tab,27 Esc,13 Enter"
LcaseKeys$ = ",59 F1,60 F2,61 F3,62 F4,63 F5,64 F6,65 F7,66 F8,67 F9,68 F10,133 F11,134 F12,82 Insert,83 Delete,73 PgUp,81 PgDn,71 Home,79 End,75 Arrow Lt,72 Arrow Up,80 Arrow Dn,77 Arrow Rt,8 Backspace,96 `,49 1,50 2,51 3,52 4,53 5,54 6,55 7,56 8,57 9,48 0,45 -,61 =,113 q,119 w,101 e,114 r,116 t,121 y,117 u,105 i,111 o,112 p,91 [,93 ],92 \,97 a,115 s,100 d,102 f,103 g,104 h,106 j,107 k,108 l,59 ;,39 ',122 z,120 x,99 c,118 v,98 b,110 n,109 m,44 ,,46 .,47 /,32 Space,9 Tab,27 Esc,13 Enter,42 *,43 +" ' Last 2 are for numlock.
CtrlKeys$ = ",94 F1,95 F2,96 F3,97 F4,98 F5,99 F6,100 F7,101 F8,102 F9,103 F10,137 F11,138 F12,146 Insert,147 Delete,132 PgDp,118 PgDn,119 Home,117 End,115 Arrow Lt,141 Arrow Up,145 Arrow Dn,116 Arrow Rt,147 Backspace,17 q,23 w,5 e,18 r,20 t,25 y,21 u,9 i,15 o,16 p,1 a,19 s,4 d,6 f,7 g,8 h,10 j,11 k,12 l,26 z,24 x,3 c,22 v,2 b,14 n,13 m,32 Space,0 2,30 6,31 -"
AltKeys$ = ",104 F1,105 F2,106 F3,108 F5,109 F6,110 F7,111 F8,112 F9,113 F10,139 F11,140 F12,162 Insert,163 Delete,153 PgDp,161 PgDn,151 Home,159 End,155 Arrow Lt,152 Arrow Up,160 Arrow Dn,157 Arrow Rt,14 Backspace,41 `,120 1,121 2,122 3,123 4,124 5,125 6,126 7,127 8,128 9,129 0,130 -,131 =,16 q,17 w,18 e,19 r,20 t,21 y,22 u,23 i,24 o,25 p,26 [,27 ],43 \,30 a,31 s,32 d,33 f,34 g,35 h,36 j,37 k,38 l,39 ;,40 ',44 z,45 x,46 c,47 v,48 b,49 n,50 m,51 , 52,. 53,/"
Do
_Limit 30
b$ = InKey$
If _KeyDown(100303) Or _KeyDown(100304) Then shift = -1 Else If shift Then shift = 0
If _KeyDown(100305) Or _KeyDown(100306) Then ctrl = -1 Else If ctrl Then ctrl = 0
If _KeyDown(100307) Or _KeyDown(100308) Then alt = -1 Else If alt Then alt = 0
If Len(b$) Then
Sound 1000, .2
If alt Then
x$ = AltKeys$
ElseIf ctrl Then x$ = CtrlKeys$
ElseIf shift Then x$ = UcaseKeys$ Else x$ = LcaseKeys$
End If
If Len(b$) = 1 Then e$ = LTrim$(Str$(Asc(b$))): seed = InStr(x$, "Arrow Rt") + 8 Else e$ = LTrim$(Str$(Asc(Mid$(b$, 2, 1)))): seed = 0
Do
j = InStr(seed, x$, "," + e$ + " ")
If j Then
key$ = Mid$(x$, j + Len(e$) + 2)
key$ = Mid$(key$, 1, InStr(key$ + ",", ",") - 1)
If shift Then
j = InStr("`1234567890-=[]\;',./", key$)
If j Then key$ = Mid$("~!@#$%^&*()_+{}|:'<>?", j, 1): If key$ = "'" Then key$ = Chr$(34)
End If
If key$ = "-Q" Then key$ = Chr$(34) ' Compensate for inability to store a quote mark in a data statement.
If shift + ctrl + alt Then If Len(key$) = 1 Then key$ = UCase$(key$)
If shift Then Print "Shift ";
If ctrl Then Print "Ctrl "; Rem If key$ = "J" Then key$ = "Enter" GLUT error. BTW _Keyhit would return 13 for Ctrl + Enter or Ctrl + J.
If alt Then Print "Alt ";
Print key$: Exit Do
Else
Print e$, b$: Sound 100, 1: Exit Do ' Something got missed!
End If
Loop
End If
Loop
I included the numlock keypad in this one. As far as AltGr, I've only had one setup with that on my keyboard. I'd have to either do a lookup, or see if virtual keyboard could be used to map those.