Gambas Documentation - /comp/gb.sdl/window/.keypress

# Event Window.KeyPress (gb.sdl)

Event KeyPress ( )

Raised when a key is pressed while the control has the focus.

You get information about the pressed key with the Key class.

### Example

    PUBLIC SUB screen_KeyPress()

      ' Move the player using the arrows keys
      IF (Key.Code = Key.Up) THEN MoveY = 1
      IF (Key.Code = Key.Down) THEN MoveY = -1
      IF (Key.Code = Key.Left) THEN MoveX = -1
      IF (Key.Code = Key.Right) THEN MoveX = 1

    END