Aab is right, GetAsyncKeyState works without giving focus to something else.
; Parent Window
Local Desk_W = ClientWidth(Desktop()), Desk_H = ClientHeight(Desktop())
Parent = CreateWindow("Text Adventure Example by Eikon", Desk_W / 2 - 320, Desk_H / 2 - 240, 640, 480, 0, 1 + 2 + 4)
SetMinWindowSize Parent, 640, 480
; Menu
Const cnt_EXIT = 1
Menu = WindowMenu(Parent)
File = CreateMenu("&File", 0, Menu)
CreateMenu "E&xit", cnt_EXIT, File
UpdateWindowMenu Parent
; Text Area
TArea = CreateTextArea(0, 0, 632, 400, Parent, 1)
SetGadgetLayout TArea, 2, 1, 2, 1
SetTextAreaText TArea, "You wake up cold and alone in a dank prison cell." + Chr$(10) + "What do you do?" + Chr$(10)
Font = LoadFont("Courier", 16, 0, 0, 0)
SetTextAreaFont TArea, Font ; Font
SetTextAreaColor TArea, 0, 0, 0, 1 ; Back Color
SetTextAreaColor TArea, 0, 255, 255, 0 ; Fore Color
TField = CreateTextField(0, 402, 632, 32, Parent, 0)
SetGadgetFont TField, Font
SetGadgetLayout TField, 1, 1, 0, 1
ActivateGadget TField ; Set focus
AutoSuspend 1
SeedRnd MilliSecs()
Repeat
Select WaitEvent()
Case $803: End ; X Out
Case $401 ; Gadget Event
Select EventData()
Case 13 ; Enter pressed
SetTextAreaText TArea, TextAreaText(TArea) + TextFieldText(TField) + Chr$(10)
SetGadgetText TField, "" ; Clear
End Select
Case $1001 ; Menu Event
If EventData() = cnt_EXIT Then End
End Select
For i = 0 To 256
If GetAsyncKeyState(i) <> 0 Then Print i
Next
Forever
*edit*
Escape works fine in the TextField, but not in the TextArea. Definitely a B+ issue, I don't have this problem in Visual Basic. The function keys also seem to have a problem. Once another valid key is pressed, all the function key values previously pressed are printed all at once.
Maybe you could fake a valid keystroke with the keybd_event function at the right time to return all function keys pressed.
*edited out*