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.
 

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

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 does not trigger accelerator commands in WebCore (eg, Ctrl+C for copy is an accelerator command).

Warning
You should probably use kType_RawKeyDown instead. 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()

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

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