Key names from Scancode

Started by empty, October 28, 2005, 08:09:11 AM

Previous topic - Next topic

empty

This example show how to get the name of key from a given scancode()


PlayBASIC Code: [Select]
; Link GetKeyNameTextA in user32.dll
LinkDll "user32.dll"
GetKeyNameText(Key, MemPointer, Length) Alias "GetKeyNameTextA"
EndLinkDll

; this function retrieves the key name of a scancode value
Psub GetScanKeyName(Scan)
If scan > 127 Then scan = scan + 128
scan = LSL32(scan, 16)
Local bank = GetFreeBank()
CreateBank bank, 64
GetKeyNameText(scan, GetBankPtr(bank), 63)
Local result$ = PeekBankString(bank, 0, 0)
DeleteBank bank
EndPsub result$


; Usage Example
Do
Cls 0
sc = ScanCode()
Print "Keyname: "
Print GetScanKeyName(sc)
Sync
Loop