This could be done into a string.
The string is empty if no key is pressed.
The string is 2 bytes long if a key is pressed.
The first byte contains, say, chr(1) if normal key, chr(2) if extended key.
The second byte is the key value.
This would allow some fast keyboard checking without massive If/ElseIf or select constructs, eg:
Code: Select all
Dim nKB.l(256) ; Normal keys jumptable
Dim xKB.l(256) ; Extended keys jumptable
; - do stuff
For k=0 To 256
nKB(k)=@stdKeyPress() ; Assume these are procedures
xKB(k)=@extKeyPress() ; that the coder has written
Next
nKB(27)=@escapeKeyPress() ; And so on for special actions
; - do stuff
ky.s=GetKeyPressed() ; The generic examine and return KB value.
If ky.s<>""
If Left(ky,1)=Chr(1)
CallFunctionFast(nKB(Asc(Mid(ky,2,1))))
Else
CallFunctionFast(xKB(Asc(Mid(ky,2,1))))
EndIf
EndIf
In normal apps (v console or gaming/screens) perhaps it could be coupled with something like:
If EventType()=#PB_Key_Pressed
And in console or gaming it is just a quick flyby check of the keyboard.