Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inkey Literal Key Display
#6
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.

Pete
Reply


Messages In This Thread
Inkey Literal Key Display - by Pete - 01-05-2026, 09:16 PM
RE: Inkey Literal Key Display - by bplus - 01-05-2026, 09:25 PM
RE: Inkey Literal Key Display - by bplus - 01-06-2026, 04:04 AM
RE: Inkey Literal Key Display - by Pete - 01-06-2026, 10:00 PM
RE: Inkey Literal Key Display - by Pete - 01-07-2026, 01:59 AM
RE: Inkey Literal Key Display - by Pete - 01-07-2026, 03:57 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Wink display unicode text(by windows api) qbfans 10 946 12-21-2025, 12:17 AM
Last Post: TDarcos
  Vacuum Flourescent Display Clock With Alarm SierraKen 5 1,196 06-07-2025, 11:02 PM
Last Post: SierraKen
  Volume display utility eoredson 0 495 09-30-2023, 01:06 AM
Last Post: eoredson

Forum Jump:


Users browsing this thread: 1 Guest(s)