Table of Contents

Class CdpKeyboard

Namespace
PuppeteerSharp.Cdp
Assembly
PuppeteerSharp.dll

Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.

public class CdpKeyboard : Keyboard, IKeyboard
Inheritance
CdpKeyboard
Implements

Methods

DownAsync(string, DownOptions)

Dispatches a keydown event.

public override Task DownAsync(string key, DownOptions options = null)

Parameters

key string

Name of key to press, such as ArrowLeft. KeyDefinitions for a list of all key names.

options DownOptions

down options.

Returns

Task

Task.

Remarks

If key is a single character and no modifier keys besides Shift are being held down, a keypress/input event will also generated. The text option can be specified to force an input event to be generated. If key is a modifier key, Shift, Meta, Control, or Alt, subsequent key presses will be sent with that modifier active. To release the modifier key, use UpAsync(string) After the key is pressed once, subsequent calls to DownAsync(string, DownOptions) will have repeat set to true. To release the key, use UpAsync(string).

PressAsync(string, PressOptions)

public override Task PressAsync(string key, PressOptions options = null)

Parameters

key string

Name of key to press, such as ArrowLeft. KeyDefinitions for a list of all key names.

options PressOptions

press options.

Returns

Task

Task.

Remarks

If key is a single character and no modifier keys besides Shift are being held down, a keypress/input event will also generated. The Text option can be specified to force an input event to be generated. Modifier keys DO effect PressAsync(string, PressOptions). Holding down Shift will type the text in upper case.

SendCharacterAsync(string)

Dispatches a keypress and input event. This does not send a keydown or keyup event.

public override Task SendCharacterAsync(string charText)

Parameters

charText string

Character to send into the page.

Returns

Task

Task.

TypeAsync(string, TypeOptions)

Sends a keydown, keypress/input, and keyup event for each character in the text.

public override Task TypeAsync(string text, TypeOptions options = null)

Parameters

text string

A text to type into a focused element.

options TypeOptions

type options.

Returns

Task

Task.

Remarks

To press a special key, like Control or ArrowDown, use PressAsync(string, PressOptions).

UpAsync(string)

Dispatches a keyup event.

public override Task UpAsync(string key)

Parameters

key string

Name of key to release, such as ArrowLeft. See KeyDefinitions for a list of all key names.

Returns

Task

Task.