I'm writing a program where I need to capture all input by the user (i.e. letters and numbers), regardless of their keyboard language. StrinGadget won't work for this specific use case, sadly. So I turned to KeyboardInkey(). The following code sample works, accept backspace and return give me non-printable characters, so they're pretty hard to filter out. What's the best way to go about this? Hook just those two keys with an if block, like I have for my escape logic? Are there more keys KeyboardInkey() catches that I don't want?
My code is as follows:
Code: Select all
InitSprite()
InitKeyboard()
OpenWindow(0, 480, 640, 400, 400, "Tester")
OpenWindowedScreen(WindowID(0), #PB_Ignore, #PB_Ignore, #PB_Ignore, #PB_Ignore)
KeyboardMode(#PB_Keyboard_AllowSystemKeys)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow
End
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
End
Else
Result$ = KeyboardInkey()
If Result$ <> ""
MessageRequester("Info", Result$)
EndIf
EndIf
ForEver