Keyboard Events

typedef uint32_t PuglMods

Bitwise OR of PuglMod values.

enum PuglCrossingMode

Reason for a PuglCrossingEvent.

enumerator PUGL_CROSSING_NORMAL

Crossing due to pointer motion.

enumerator PUGL_CROSSING_GRAB

Crossing due to a grab.

enumerator PUGL_CROSSING_UNGRAB

Crossing due to a grab release.

enum PuglKey

Keyboard key codepoints.

All keys are identified by a Unicode code point in PuglKeyEvent.key. This enumeration defines constants for special keys that don’t have a standard code point, and some convenience constants for control characters. Note that all keys are handled in the same way, this enumeration is just for convenience when writing hard-coded key bindings.

Keys that don’t have a standard code point use values in the Private Use Area in the Basic Multilingual Plane (U+E000 to U+F8FF). Applications must take care to not interpret these values beyond key detection, the mapping used here is arbitrary and specific to Pugl.

enumerator PUGL_KEY_NONE

Sentinel value for no key.

enumerator PUGL_KEY_BACKSPACE

Backspace.

enumerator PUGL_KEY_TAB

Tab.

enumerator PUGL_KEY_ENTER

Enter.

enumerator PUGL_KEY_ESCAPE

Escape.

enumerator PUGL_KEY_DELETE

Delete.

enumerator PUGL_KEY_SPACE

Space.

enumerator PUGL_KEY_F1

F1.

enumerator PUGL_KEY_F2

F2.

enumerator PUGL_KEY_F3

F3.

enumerator PUGL_KEY_F4

F4.

enumerator PUGL_KEY_F5

F5.

enumerator PUGL_KEY_F6

F6.

enumerator PUGL_KEY_F7

F7.

enumerator PUGL_KEY_F8

F8.

enumerator PUGL_KEY_F9

F9.

enumerator PUGL_KEY_F10

F10.

enumerator PUGL_KEY_F11

F11.

enumerator PUGL_KEY_F12

F12.

enumerator PUGL_KEY_PAGE_UP

Page Up.

enumerator PUGL_KEY_PAGE_DOWN

Page Down.

enumerator PUGL_KEY_END

End.

enumerator PUGL_KEY_HOME

Home.

enumerator PUGL_KEY_LEFT

Left.

enumerator PUGL_KEY_UP

Up.

enumerator PUGL_KEY_RIGHT

Right.

enumerator PUGL_KEY_DOWN

Down.

enumerator PUGL_KEY_PRINT_SCREEN

Print Screen.

enumerator PUGL_KEY_INSERT

Insert.

enumerator PUGL_KEY_PAUSE

Pause/Break.

enumerator PUGL_KEY_MENU

Menu.

enumerator PUGL_KEY_NUM_LOCK

Num Lock.

enumerator PUGL_KEY_SCROLL_LOCK

Scroll Lock.

enumerator PUGL_KEY_CAPS_LOCK

Caps Lock.

enumerator PUGL_KEY_SHIFT_L

Left Shift.

enumerator PUGL_KEY_SHIFT_R

Right Shift.

enumerator PUGL_KEY_CTRL_L

Left Control.

enumerator PUGL_KEY_CTRL_R

Right Control.

enumerator PUGL_KEY_ALT_L

Left Alt.

enumerator PUGL_KEY_ALT_R

Right Alt / AltGr.

enumerator PUGL_KEY_SUPER_L

Left Super.

enumerator PUGL_KEY_SUPER_R

Right Super.

enumerator PUGL_KEY_PAD_0

Keypad 0.

enumerator PUGL_KEY_PAD_1

Keypad 1.

enumerator PUGL_KEY_PAD_2

Keypad 2.

enumerator PUGL_KEY_PAD_3

Keypad 3.

enumerator PUGL_KEY_PAD_4

Keypad 4.

enumerator PUGL_KEY_PAD_5

Keypad 5.

enumerator PUGL_KEY_PAD_6

Keypad 6.

enumerator PUGL_KEY_PAD_7

Keypad 7.

enumerator PUGL_KEY_PAD_8

Keypad 8.

enumerator PUGL_KEY_PAD_9

Keypad 9.

enumerator PUGL_KEY_PAD_ENTER

Keypad Enter.

enumerator PUGL_KEY_PAD_PAGE_UP

Keypad Page Up.

enumerator PUGL_KEY_PAD_PAGE_DOWN

Keypad Page Down.

enumerator PUGL_KEY_PAD_END

Keypad End.

enumerator PUGL_KEY_PAD_HOME

Keypad Home.

enumerator PUGL_KEY_PAD_LEFT

Keypad Left.

enumerator PUGL_KEY_PAD_UP

Keypad Up.

enumerator PUGL_KEY_PAD_RIGHT

Keypad Right.

enumerator PUGL_KEY_PAD_DOWN

Keypad Down.

enumerator PUGL_KEY_PAD_CLEAR

Keypad Clear/Begin.

enumerator PUGL_KEY_PAD_INSERT

Keypad Insert.

enumerator PUGL_KEY_PAD_DELETE

Keypad Delete.

enumerator PUGL_KEY_PAD_EQUAL

Keypad Equal.

enumerator PUGL_KEY_PAD_MULTIPLY

Keypad Multiply.

enumerator PUGL_KEY_PAD_ADD

Keypad Add.

enumerator PUGL_KEY_PAD_SEPARATOR

Keypad Separator.

enumerator PUGL_KEY_PAD_SUBTRACT

Keypad Subtract.

enumerator PUGL_KEY_PAD_DECIMAL

Keypad Decimal.

enumerator PUGL_KEY_PAD_DIVIDE

Keypad Divide.

enum PuglMod

Keyboard modifier flags.

enumerator PUGL_MOD_SHIFT

Shift pressed.

enumerator PUGL_MOD_CTRL

Control pressed.

enumerator PUGL_MOD_ALT

Alt/Option pressed.

enumerator PUGL_MOD_SUPER

Super/Command/Windows pressed.

enumerator PUGL_MOD_NUM_LOCK

Num lock enabled.

enumerator PUGL_MOD_SCROLL_LOCK

Scroll lock enabled.

enumerator PUGL_MOD_CAPS_LOCK

Caps lock enabled.

struct PuglFocusEvent

Keyboard focus event.

This is sent whenever the view gains or loses the keyboard focus. The view with the keyboard focus will receive any key press or release events.

PuglEventType type

PuglEventType.PUGL_FOCUS_IN or PuglEventType.PUGL_FOCUS_OUT

PuglEventFlags flags

Bitwise OR of PuglEventFlag values.

PuglCrossingMode mode

Reason for focus change.

struct PuglKeyEvent

Key press or release event.

This represents low-level key presses and releases. This can be used for “direct” keyboard handling like key bindings, but must not be interpreted as text input.

Keys are represented portably as Unicode code points, using the “natural” code point for the key where possible (see PuglKey for details). The key field is the code for the pressed key, without any modifiers applied. For example, a press or release of the ‘A’ key will have key 97 (‘a’) regardless of whether shift or control are being held.

Alternatively, the raw keycode can be used to work directly with physical keys, but note that this value isn’t portable and differs between platforms and hardware.

PuglEventType type

PuglEventType.PUGL_KEY_PRESS or PuglEventType.PUGL_KEY_RELEASE

PuglEventFlags flags

Bitwise OR of PuglEventFlag values.

double time

Time in seconds.

double x

View-relative X coordinate.

double y

View-relative Y coordinate.

double xRoot

Root-relative X coordinate.

double yRoot

Root-relative Y coordinate.

PuglMods state

Bitwise OR of PuglMod flags.

uint32_t keycode

Raw key code.

uint32_t key

Unshifted Unicode character code, or 0.

struct PuglTextEvent

Character input event.

This represents text input, usually as the result of a key press. The text is given both as a Unicode character code and a UTF-8 string.

Note that this event is generated by the platform’s input system, so there isn’t necessarily a direct correspondence between text events and physical key presses. For example, with some input methods a sequence of several key presses will generate a single character.

PuglEventType type

PuglEventType.PUGL_TEXT

PuglEventFlags flags

Bitwise OR of PuglEventFlag values.

double time

Time in seconds.

double x

View-relative X coordinate.

double y

View-relative Y coordinate.

double xRoot

Root-relative X coordinate.

double yRoot

Root-relative Y coordinate.

PuglMods state

Bitwise OR of PuglMod flags.

uint32_t keycode

Raw key code.

uint32_t character

Unicode character code.

char string[8]

UTF-8 string.