Ultralight  1.0.0
A fast, lightweight, HTML UI engine for native apps.
ultralight::KeyEvent Class Reference

A generic keyboard event that can be created from a platform event or synthesized from scratch. More...

#include <KeyEvent.h>

Public Types

enum  Type { kType_KeyDown, kType_KeyUp, kType_RawKeyDown, kType_Char }
 The various KeyEvent types. More...
 
enum  Modifiers : uint8_t { kMod_AltKey = 1 << 0, kMod_CtrlKey = 1 << 1, kMod_MetaKey = 1 << 2, kMod_ShiftKey = 1 << 3 }
 An enumeration of the different keyboard modifiers. More...
 

Public Member Functions

 KeyEvent ()
 Creates an empty KeyEvent, you will need to initialize its members yourself. More...
 

Public Attributes

unsigned modifiers
 The current state of the keyboard. More...
 
int native_key_code
 The actual key-code generated by the platform. More...
 
String key_identifier
 This is a string identifying the key that was pressed. More...
 
String text
 The actual text generated by this keyboard event. More...
 
String unmodified_text
 The text generated by this keyboard event before all modifiers except shift are applied. More...
 
bool is_keypad
 Whether or not this is a keypad event.
 
bool is_auto_repeat
 Whether or not this was generated as the result of an auto-repeat (eg, holding down a key).
 
bool is_system_key
 Whether or not the pressed key is a "system key". More...
 

Detailed Description

A generic keyboard event that can be created from a platform event or synthesized from scratch.

See also
View::FireKeyEvent

Definition at line 30 of file KeyEvent.h.

Member Enumeration Documentation

◆ Modifiers

An enumeration of the different keyboard modifiers.

Enumerator
kMod_AltKey 

Whether or not an ALT key is down.

kMod_CtrlKey 

Whether or not a Control key is down.

kMod_MetaKey 

Whether or not a meta key (Command-key on Mac, Windows-key on Win) is down.

kMod_ShiftKey 

Whether or not a Shift key is down.

Definition at line 72 of file KeyEvent.h.

◆ Type

The various KeyEvent types.

Enumerator
kType_KeyDown 

Key-Down type.

kType_KeyUp 

Key-Up type.

kType_RawKeyDown 

Raw Key-Down type.

kType_Char 

Character input type (this event generates text in input fields)

Definition at line 35 of file KeyEvent.h.

Constructor & Destructor Documentation

◆ KeyEvent()

ultralight::KeyEvent::KeyEvent ( )

Creates an empty KeyEvent, you will need to initialize its members yourself.

This is useful for synthesizing your own keyboard events.

Member Data Documentation

◆ is_system_key

bool ultralight::KeyEvent::is_system_key

Whether or not the pressed key is a "system key".

This is a Windows-only concept and should be "false" for all non-Windows platforms. For more information, see the following link: http://msdn.microsoft.com/en-us/library/ms646286(VS.85).aspx

Definition at line 149 of file KeyEvent.h.

◆ key_identifier

String ultralight::KeyEvent::key_identifier

This is a string identifying the key that was pressed.

This can be generated from the virtual_key_code via the GetKeyIdentifierFromVirtualKeyCode() utility function. You can find the full list of key identifiers at: http://www.w3.org/TR/DOM-Level-3-Events/keyset.html

Definition at line 118 of file KeyEvent.h.

◆ modifiers

unsigned ultralight::KeyEvent::modifiers

The current state of the keyboard.

Modifiers may be OR'd together to represent multiple values.

Definition at line 95 of file KeyEvent.h.

◆ native_key_code

int ultralight::KeyEvent::native_key_code

The actual key-code generated by the platform.

The DOM spec primarily uses Windows-equivalent codes (hence virtualKeyCode above) but it helps to also specify the platform-specific key-code as well.

Definition at line 110 of file KeyEvent.h.

◆ text

String ultralight::KeyEvent::text

The actual text generated by this keyboard event.

This is usually only a single character.

Definition at line 124 of file KeyEvent.h.

◆ unmodified_text

String ultralight::KeyEvent::unmodified_text

The text generated by this keyboard event before all modifiers except shift are applied.

This is used internally for working out shortcut keys. This is usually only a single character.

Definition at line 131 of file KeyEvent.h.


The documentation for this class was generated from the following file: