'Device info PublicMouseStateAsDIMOUSESTATE PublicKeyboardStateAsDIKEYBOARDSTATE
PublicTypeDi_Key 'This
value is true whenever the key is pressed PressedAsBoolean 'This
value is true only right when the user presses the key ActiveAsBoolean NotLetUpAsBoolean EndType
PublicSubDIGetMouseState() 'Gets
the coords and button status from the mouse DI_Mouse.GetDeviceStateMouseMouseState EndSub PublicSubDIGetKeyboardState() 'Polls
the keyboard DI_Keyboard.GetDeviceStateKeyboardKeyboardState EndSub PublicFunctionPollKeyboard()AsString 'Polls
the keyboard and returns a string DimKeyCountAsLong ForKeyCount=0To255 IfKeyboardState.key(KeyCount)<>0Then PollKeyboard=StringFromKeycode(KeyCount) EndIf Next EndFunction
PublicSubGetKeys()
'Loop counter DimKeyCountAsLong
'Get the current state of the keyboard
DIGetKeyboardState 'Scan through all the keys to check which are depressed 'Active is only true right when the user presses
the key 'Pressed is true as long as the key is depressed ForKeyCount=1To255 IfKeyboardState.key(KeyCount)<>0Then IfDi_Keys(KeyCount).Active=FalseAndDi_Keys(KeyCount).NotLetUp=FalseThen Di_Keys(KeyCount).Active=True Di_Keys(KeyCount).NotLetUp=True Else IfDi_Keys(KeyCount).NotLetUp=TrueThenDi_Keys(KeyCount).Active=False EndIf Di_Keys(KeyCount).Pressed=True Else Di_Keys(KeyCount).NotLetUp=False Di_Keys(KeyCount).Active=False Di_Keys(KeyCount).Pressed=False EndIf Next EndSub