docs
Loading...
Searching...
No Matches
KeyboardEvent

#include <Ultralight/dom/Event.h>

Overview

A keyboard event (KeyboardEvent).

Get one with Event::AsKeyboard(). It works for keydown, keyup, and keypress.

Inheritance diagram for KeyboardEvent:
Event

Public Member Functions

 KeyboardEvent (ULDOMEvent borrowed)
 Wrap an event handle from the C API (Event::AsKeyboard() is the usual way to get one).
std::string key () const
 Get the key's value (key).
std::string code () const
 Get the physical key (code).
unsigned location () const
 Get the key's location on the keyboard (location).
bool repeat () const
 Whether or not the key is held down and repeating (repeat).
bool isComposing () const
 Whether or not the event happened during IME composition (isComposing).
bool ctrlKey () const
 Whether or not the Control key was held down (ctrlKey).
bool shiftKey () const
 Whether or not the Shift key was held down (shiftKey).
bool altKey () const
 Whether or not the Alt key was held down (altKey).
bool metaKey () const
 Whether or not the Meta key was held down (metaKey).
Public Member Functions inherited from Event
 Event (ULDOMEvent borrowed)
 Wrap an event handle from the C API.
 Event (const Event &)=delete
Event & operator= (const Event &)=delete
std::string type () const
 Get the event's type (type).
unsigned eventPhase () const
 Get the current dispatch phase (eventPhase).
bool bubbles () const
 Whether or not the event bubbles up the tree (bubbles).
bool cancelable () const
 Whether or not preventDefault() can cancel the event (cancelable).
bool isTrusted () const
 Whether or not the event came from user input or the library (isTrusted).
double timeStamp () const
 Get the time the event was created (timeStamp).
bool defaultPrevented () const
 Whether or not the event was canceled (defaultPrevented).
void preventDefault () const
 Cancel the event's default action (preventDefault).
void stopPropagation () const
 Stop the event from reaching other targets (stopPropagation).
void stopImmediatePropagation () const
 Stop the event from reaching any other listener (stopImmediatePropagation).
Element target () const
 Get the element the event was dispatched to (target).
Node targetNode () const
 Get the node the event was dispatched to (target).
Element currentTarget () const
 Get the element whose listener is running (currentTarget).
MouseEvent AsMouse () const
 View this event as a MouseEvent.
WheelEvent AsWheel () const
 View this event as a WheelEvent.
KeyboardEvent AsKeyboard () const
 View this event as a KeyboardEvent.
FocusEvent AsFocus () const
 View this event as a FocusEvent.
InputEvent AsInput () const
 View this event as an InputEvent.
SubmitEvent AsSubmit () const
 View this event as a SubmitEvent.
CustomEvent AsCustom () const
 View this event as a CustomEvent.
ULDOMEvent raw () const
 Get the C handle, for passing to the <Ultralight/CAPI/CAPI_DOMEvent.h> functions.

Constructor & Destructor Documentation

◆ KeyboardEvent()

KeyboardEvent ( ULDOMEvent borrowed)
inlineexplicit

Wrap an event handle from the C API (Event::AsKeyboard() is the usual way to get one).

Parameters
borrowedThe event handle passed to a C listener callback.

Member Function Documentation

◆ altKey()

bool altKey ( ) const
inline

Whether or not the Alt key was held down (altKey).

◆ code()

std::string code ( ) const
inline

Get the physical key (code).

Returns
Returns the physical key (eg, KeyA or Numpad1). Returns an empty string if it isn't known.
Note
The physical key is known only for a KeyEvent you created from a Windows key message. For other key events this is empty, so use key() in code that must work on every platform.

◆ ctrlKey()

bool ctrlKey ( ) const
inline

Whether or not the Control key was held down (ctrlKey).

◆ isComposing()

bool isComposing ( ) const
inline

Whether or not the event happened during IME composition (isComposing).

◆ key()

std::string key ( ) const
inline

Get the key's value (key).

Returns
Returns the value (eg, a, Enter, or ArrowLeft). Returns an empty string for an event that isn't a keyboard event.

◆ location()

unsigned location ( ) const
inline

Get the key's location on the keyboard (location).

Returns
Returns 0 for a standard key, 1 for the left key of a pair (eg, left Shift), 2 for the right one, or 3 for the numeric keypad.

◆ metaKey()

bool metaKey ( ) const
inline

Whether or not the Meta key was held down (metaKey).

◆ repeat()

bool repeat ( ) const
inline

Whether or not the key is held down and repeating (repeat).

◆ shiftKey()

bool shiftKey ( ) const
inline

Whether or not the Shift key was held down (shiftKey).


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