GXKeyInput - boxgaming/gx GitHub Wiki

Syntax

GXKeyInput keyCode%, deviceInput As GXDeviceInput

Description

Convenience method to define a device input for a keyboard key.

Parameters

  • The keyCode% parameter indicates the keyboard key for which the device input will be defined.
    The value of the keyCode% parameter must be one of the Key Codes constants.
  • The deviceInput parameter is a GXDeviceInput type which will be configured by the method for testing whether the indicated key is pressed.

Examples

Example1: Create a scene and start the game loop. Exit the game loop when the user presses the ESC key.

'$Include: 'gx.bi'

Dim Shared diQuit As GXDeviceInput
GXKeyInput GXKEY_ESC, diQuit

GXSceneCreate 320, 200
GXSceneStart
PRINT "Game Over"

Sub GXOnGameEvent (e As GXEvent)
    Select Case e.event
        Case GXEVENT_UPDATE
            If GXDeviceInputTest(diQuit) Then GXSceneStop
    End Select
End Sub

'$Include: 'gx.bm'

See Also

Key Codes
GXKeyDown
GXKeyInput
GXDeviceInputDetect