Skip to main content

LensStudio:Ui.KeyEvent

Class

Input event describing a keyboard key press, including key code, modifiers, and text.

Index

Example

const UiTest = await import('LensStudio:UiTest');
const { Key, KeyboardModifier } = await import('LensStudio:Ui');

const ctrlA = UiTest.KeyEvent(
UiTest.EventType.KeyPress,
Key.Key_A,
KeyboardModifier.ControlModifier,
'a',
);
console.log(`KeyEvent: key=${ctrlA.key} modifiers=${ctrlA.modifiers} text="${ctrlA.text}"`);

Extends

Properties

key

readonly key: Key

Key code identifying which key triggered the event.


modifiers

readonly modifiers: KeyboardModifier

Bitmask of keyboard modifiers (Shift, Ctrl, Alt, Meta) active when the key was pressed.


text

readonly text: string

Unicode text produced by the key press, if any.

Methods

accept()

accept(): void

Marks the event as handled so it will not propagate further.

Returns

void

Inherited from

Event.accept


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

Event.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

Event.getTypeName


ignore()

ignore(): void

Marks the event as unhandled so it propagates to parent widgets.

Returns

void

Inherited from

Event.ignore


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

Event.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

Event.isSame