toyGraphics / com.anysolo.toyGraphics / Keyboard

Keyboard

class Keyboard

Use this class to work with keyboard

You can work with keyboard in two modes. If eventMode == false the keyboard collects Key objects. You receive these object calling getPressedKey() method. This mode is easier but you cannot detect when a key was released. Also Ctrl, Alt, Shift, Meta keys will be treated as modifiers for normal keys. For instance, you cannot detect when Ctrl was pressed.

If eventMode == true the keyboard collects KeyboardEvent objects. You get those objects calling getEvent() method. In this mode modifier keys will be treated as normal keys. You also will receive event for both pressed and released keys.

Constructors

<init>

Keyboard(window: Window, eventMode: Boolean = false)

Use this class to work with keyboard

Properties

window

val window: Window

Functions

getEvent

fun getEvent(): KeyboardEvent?

Return a keyboard event or null. Event are collected in the queue. If the queue is empty it returns null You must create the keyboard with evenMode=true to use this function.

getPressedKey

fun getPressedKey(): Key?

Returns the pressed key. Pressed keys are collected in the queue. This function returns a pressed key from keyboard queue. If the queue is empty it returns null You must create the keyboard with evenMode=false to use this function.