Skip to content

CdpKeyboard

Namespace: PuppeteerSharp.Cdp

public class CdpKeyboard : Keyboard, IKeyboard

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.

Inheritance: object → Keyboard

Implements: IKeyboard

View source

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

Dispatches a keydown event.

Parameters

Name Type Description
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.

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 DownOptions) will have <a href=“https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat"&gt;repeat&lt;/a> set to true. To release the key, use UpAsync(string).

View source

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

Shortcut for DownOptions) and UpAsync(string).

Parameters

Name Type Description
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.

If <code class=“paramref”>key</code> 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 PressOptions). Holding down Shift will type the text in upper case.

View source

public override Task SendCharacterAsync(string charText)

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

Parameters

Name Type Description
charText string Character to send into the page.

Returns: Task — Task.

View source

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

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

Parameters

Name Type Description
text string A text to type into a focused element.
options TypeOptions type options.

Returns: Task — Task.

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

View source

public override Task UpAsync(string key)

Dispatches a keyup event.

Parameters

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

Returns: Task — Task.

View source

Made with love by Dario Kondratiuk