Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Alt-Keys pattern
#1
I have been looking at the keyboard scancodes for the keys Alt-A to Alt-Z and found no pattern to them!

Are they internal to the electronic keyboard itself?

Thanks, Erik.

Here is a program to trap and display them:

Code: (Select All)
Rem $Dynamic
DefInt A-Z

Dim Keys(1 To 26) As Integer

' scancodes for Alt-A to Alt-Z.
Data 30,48,46,32,18,33,34,35,23,36,37,38,50,49,24,25,16,19,31,20,22,47,17,45,21,44

' read Alt-<key> data.
For Var = 1 To 26
    Read Keys(Var)
Next
Color 15
Print "Press <escape> to exit. Otherwise press Alt-A to Alt-Z."
Color 14
Do
    _Limit 50
    I$ = InKey$
    If Len(I$) Then
        If I$ = Chr$(27) Then Color 7: End
    End If
    If Len(I$) = 2 Then
        X = Asc(Right$(I$, 1))
        For Z = 1 To 26
            If Keys(Z) = X Then
                Print "Pressed Alt-"; Chr$(Z + 64); " scan"; X
            End If
        Next
    End If
Loop
End

' scancodes for Alt-A to Alt-Z.
Rem ALT-A = 30
Rem ALT-B = 48
Rem ALT-C = 46
Rem ALT-D = 32
Rem ALT-E = 18
Rem ALT-F = 33
Rem ALT-G = 34
Rem ALT-H = 35
Rem ALT-I = 23
Rem ALT-J = 36
Rem ALT-K = 37
Rem ALT-L = 38
Rem ALT-M = 50
Rem ALT-N = 49
Rem ALT-O = 24
Rem ALT-P = 25
Rem ALT-Q = 16
Rem ALT-R = 19
Rem ALT-S = 31
Rem ALT-T = 20
Rem ALT-U = 22
Rem ALT-V = 47
Rem ALT-W = 17
Rem ALT-X = 45
Rem ALT-Y = 21
Rem ALT-Z = 44
Reply
#2
https://qb64phoenix.com/qb64wiki/index.php/KEYHIT

Page for _KEYDOWN displays the same chart but this function should be used to detect the states of the shift keys. Using INKEY$ is becoming a little bit outdated these days and some combinations don't work. You should know that by now... trying to trap [CTRL][ALT][DEL] or some other system-wide combination like that.
Reply
#3
Erik try detecting with _KeyHit eg:
Code: (Select All)
Do
    alt = _KeyDown(100308) Or _KeyDown(100307)
    If _KeyDown(27) Then End
    kh = _KeyHit
    If (kh >= 65 And kh <= 90) Or (kh >= 97 And kh <= 122) Then
        If alt Then
            Print "Alt + "; Chr$(kh)
        Else
            Print Chr$(kh)
        End If
    End If
Loop
b = b + ...
Reply
#4
My current custom Inkey$ function is thus:

Code: (Select All)
Function INKEYz$
    _Limit 100
    X = _KeyHit
    If X Then
        If X < 0 Then
            Select Case X
                Case -12 ' keypad-5
                    INKEYz$ = Chr$(0) + Chr$(76)
                    KeyPressed = -1
                Case -108 ' ctrl-keypad-5
                    INKEYz$ = Chr$(0) + Chr$(143)
                    KeyPressed = -1
            End Select
        Else
            X$ = InKey$
            If Len(X$) Then
                INKEYz$ = X$
                KeyPressed = -1
            End If
        End If
    End If
End Function

Note: Inkey$ does not trap Keypad-5 or Ctrl-Keypad-5.
Reply




Users browsing this thread: 1 Guest(s)