docs
Loading...
Searching...
No Matches
KeyEvent

#include <Ultralight/KeyEvent.h>

Overview

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.
 KeyEvent (const KeyEvent &other)
 Copy constructor.
KeyEvent & operator= (const KeyEvent &other)
 Copy assignment.
 KeyEvent (KeyEvent &&other) noexcept
 Move constructor.
KeyEvent & operator= (KeyEvent &&other) noexcept
 Move assignment.
 ~KeyEvent ()

Public Attributes

Type type
 The type of this KeyEvent.
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".
PlatformKeyEvent * platform_event = nullptr
 Internal, platform-specific key event data (set by the library's own platform integrations).

Member Enumeration Documentation

◆ Modifiers

enum Modifiers : uint8_t

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

enum Type

The various KeyEvent types.

Enumerator
kType_KeyDown 

Key-Down event type.

This type combines a key press with its text input: it triggers editing shortcuts (eg, Ctrl+C for copy) and, when text is set, also inserts that text.

Warning
You should probably use kType_RawKeyDown instead (followed by a kType_Char event for any text). 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.

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() [1/3]

KeyEvent ( )

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

This is useful for synthesizing your own keyboard events.

◆ KeyEvent() [2/3]

KeyEvent ( const KeyEvent & other)

Copy constructor.

◆ KeyEvent() [3/3]

KeyEvent ( KeyEvent && other)
noexcept

Move constructor.

◆ ~KeyEvent()

~KeyEvent ( )

Member Function Documentation

◆ operator=() [1/2]

KeyEvent & operator= ( const KeyEvent & other)

Copy assignment.

◆ operator=() [2/2]

KeyEvent & operator= ( KeyEvent && other)
noexcept

Move assignment.

Member Data Documentation

◆ is_auto_repeat

bool is_auto_repeat

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

◆ is_keypad

bool is_keypad

Whether or not this is a keypad event.

◆ is_system_key

bool 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 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 modifiers

The current state of the keyboard.

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

◆ native_key_code

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

◆ platform_event

PlatformKeyEvent* platform_event = nullptr

Internal, platform-specific key event data (set by the library's own platform integrations).

Leave this null when creating events yourself.

◆ text

String text

The actual text generated by this keyboard event.

This is usually only a single character.

◆ type

Type type

The type of this KeyEvent.

◆ unmodified_text

String 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 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: