You can do it using User32.dll. I put together this quick test code to demonstrate:
//Some Info: http://www.pinvoke.net/default.aspx/user32.keybd_event
//Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/ms645540
disable escapekey
#Constant User32 1
load dll "user32.dll",User32
repeat
cls
//Virtual Keypresses:
`CALL DLL User32,"keybd_event",VirtualKeycode,Scancode,action?,0
`Press the "a" key
CALL DLL User32,"keybd_event",0x41,30,0x1,0
`Release the "a" key
CALL DLL User32,"keybd_event",0x41,30,0x1||0x2,0
`Press the "b" key
CALL DLL User32,"keybd_event",0x42,48,0x1,0
`Release the "b" key
CALL DLL User32,"keybd_event",0x42,48,0x1||0x2,0
CurCommand$=entry$()
if CurCommand$<>""
clear entry buffer
LastCommand$=CurCommand$
endif
set cursor 0,0
print LastCommand$
until escapekey()=1