Table of Contents

Class KeyboardEvent

Namespace
AngleSharp.Html.Dom.Events
Assembly
AngleSharp.dll

Represents the event arguments for a keyboard event.

[DomName("KeyboardEvent")]
public class KeyboardEvent : UiEvent
Inheritance
KeyboardEvent
Inherited Members
Extension Methods

Constructors

KeyboardEvent()

Creates a new event.

public KeyboardEvent()

KeyboardEvent(string, bool, bool, IWindow?, int, string?, KeyboardLocation, string?, bool)

Creates a new event and initializes it.

[DomConstructor]
[DomInitDict(1, true)]
public KeyboardEvent(string type, bool bubbles = false, bool cancelable = false, IWindow? view = null, int detail = 0, string? key = null, KeyboardLocation location = KeyboardLocation.Standard, string? modifiersList = null, bool repeat = false)

Parameters

type string

The type of the event.

bubbles bool

If the event is bubbling.

cancelable bool

If the event is cancelable.

view IWindow

Sets the associated view for the UI event.

detail int

Sets the detail id for the UI event.

key string

Sets the key that is currently pressed.

location KeyboardLocation

Sets the position of the originating keyboard.

modifiersList string

A list with keyboard modifiers that have been pressed.

repeat bool

Sets if the key has been pressed again.

Properties

IsAltPressed

Gets if the alt key is pressed.

[DomName("altKey")]
public bool IsAltPressed { get; }

Property Value

bool

IsCtrlPressed

Gets if the control key is pressed.

[DomName("ctrlKey")]
public bool IsCtrlPressed { get; }

Property Value

bool

IsMetaPressed

Gets if the meta key is pressed.

[DomName("metaKey")]
public bool IsMetaPressed { get; }

Property Value

bool

IsRepeated

Gets if the key press was repeated.

[DomName("repeat")]
public bool IsRepeated { get; }

Property Value

bool

IsShiftPressed

Gets if the shift key is pressed.

[DomName("shiftKey")]
public bool IsShiftPressed { get; }

Property Value

bool

Key

Gets string representation of the pressed key.

[DomName("key")]
public string? Key { get; }

Property Value

string

Locale

Gets the locale of the keyboard.

[DomName("locale")]
public string? Locale { get; }

Property Value

string

Location

Gets the location of the keyboard that initiated the event.

[DomName("location")]
public KeyboardLocation Location { get; }

Property Value

KeyboardLocation

Methods

GetModifierState(string)

Returns the current state of the specified modifier key.

[DomName("getModifierState")]
public bool GetModifierState(string key)

Parameters

key string

The modifier key to lookup.

Returns

bool

True if the key is currently pressed, otherwise false.

Init(string, bool, bool, IWindow?, int, string, KeyboardLocation, string, bool)

Initializes the keyboard event.

[DomName("initKeyboardEvent")]
public void Init(string type, bool bubbles, bool cancelable, IWindow? view, int detail, string key, KeyboardLocation location, string modifiersList, bool repeat)

Parameters

type string

The type of event.

bubbles bool

Determines if the event bubbles.

cancelable bool

Determines if the event is cancelable.

view IWindow

Sets the associated view for the UI event.

detail int

Sets the detail id for the UI event.

key string

Sets the key that is currently pressed.

location KeyboardLocation

Sets the position of the originating keyboard.

modifiersList string

A list with keyboard modifiers that have been pressed.

repeat bool

Sets if the key has been pressed again.