Ultralight C++ API 1.3.0
Loading...
Searching...
No Matches
ultralight::KeyEvent Class Reference

#include <Ultralight/KeyEvent.h>

Details

Generic keyboard event representing a change in keyboard state.

See also
View::FireKeyEvent

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.
 

Public Attributes

Type type
 
unsigned modifiers
 The current state of the keyboard.
 
int virtual_key_code
 The virtual key-code associated with this keyboard event.
 
int native_key_code
 The actual key-code generated by the platform.
 
String key_identifier
 This is a string identifying the key that was pressed.
 
String text
 The actual text generated by this keyboard event.
 
String unmodified_text
 The text generated by this keyboard event before all modifiers except shift are applied.
 
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".
 

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.

◆ Type

The various KeyEvent types.

Enumerator
kType_KeyDown 

Key-Down event type.

(Does not trigger accelerator commands in WebCore)

@NOTE: You should probably use RawKeyDown instead when a physical key is pressed. This type is only here for historic compatibility with WebCore's key event types.

kType_KeyUp 

Key-Up event type.

Use this when a physical key is released.

kType_RawKeyDown 

Raw Key-Down type.

Use this when a physical key is pressed.

@NOTE: You should use RawKeyDown for physical key presses since it allows the renderer to handle accelerator command translation.

kType_Char 

Character input event type.

Use this when the OS generates text from a physical key being pressed (for example, this maps to WM_CHAR on Windows).

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_auto_repeat

bool ultralight::KeyEvent::is_auto_repeat

Whether or not this was generated as the result of an auto-repeat (eg, holding down a key).

◆ is_keypad

bool ultralight::KeyEvent::is_keypad

Whether or not this is a keypad event.

◆ 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

◆ 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: https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/keyset.html

◆ modifiers

unsigned ultralight::KeyEvent::modifiers

The current state of the keyboard.

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

◆ 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.

◆ text

String ultralight::KeyEvent::text

The actual text generated by this keyboard event.

This is usually only a single character.

◆ type

Type ultralight::KeyEvent::type

◆ 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.

◆ virtual_key_code

int ultralight::KeyEvent::virtual_key_code

The virtual key-code associated with this keyboard event.

This is either directly from the event (ie, WPARAM on Windows) or via a mapping function. You can see a full list of the possible virtual key-codes in KeyCodes.h


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