08-15-2024, 03:40 PM
Here is a modified version of the _KEYHIT Wiki example...
Do this...
PRESS ALT.
RELEASE ALT.
So why does it record just the SDK value when alt is pressed, but records both the SDK and ASCII values when released? I'd feel better about the operation if it did not cycle back to deliver the -18 ASCII value after previously delivering the -308 SDK value when the Alt key was released.
Pete
Code: (Select All)
DefLng A-Z
Screen _NewImage(800, 600, 8)
Cls , 1
font = _LoadFont("cyberbit.ttf", 24)
unifont = _LoadFont("cyberbit.ttf", 24, "UNICODE")
_Font font
Do
x = _KeyHit
If x And x <> oldx Then
Select Case x
Case Is > 0
Color 10
Print "Pressed "; 'positive value means key pressed
oldx = x
Case Else 'negative value means key released
Color 2
Print "Released ";
x = -x
oldx = 0
End Select
Select Case x
Case Is < 256
If x < 256 Then 'ASCII code values
Print "ASCII "; x;
If x >= 32 And x <= 255 Then Print "[" + Chr$(x) + "]" Else Print
End If
Case 256 To 65536 '2 byte key codes
Print "2-BYTE-COMBO "; x And 255; x \ 256;
x2 = x \ 256
If x2 >= 32 And x2 <= 255 Then Print "[" + Chr$(x2) + "]" Else Print
Case 100000 To 199999 'QB64 Virtual Key codes
Print "SDL VK"; x - 100000
Case Else
If x >= 200000 And x < &H40000000 Then
Print "QB64 VK"; x - 200000
_Continue
End If
If x >= &H40000000 Then 'Unicode values (IME Input mode)
Print "UNICODE "; x - &H40000000; "0x" + Hex$(x - &H40000000) + " ...";
cx = Pos(1): cy = CsrLin
_Font unifont
Locate cy, cx
Color 15
z$ = MKL$(x - &H40000000) + MKL$(0)
Print z$ + z$ + z$;
_Font font
Locate cy, 1: Print
End If
End Select
End If
Loop
Do this...
PRESS ALT.
RELEASE ALT.
So why does it record just the SDK value when alt is pressed, but records both the SDK and ASCII values when released? I'd feel better about the operation if it did not cycle back to deliver the -18 ASCII value after previously delivering the -308 SDK value when the Alt key was released.
Pete
Fake News + Phony Politicians = Real Problems