CdpKeyboard
Namespace: PuppeteerSharp.Cdp
public class CdpKeyboard : Keyboard, IKeyboardSupports 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
Methods
Section titled “Methods”DownAsync(string, DownOptions)
Section titled “DownAsync(string, DownOptions)”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">repeat</a> set to true. To release the key, use UpAsync(string).
PressAsync(string, PressOptions)
Section titled “PressAsync(string, PressOptions)”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.
SendCharacterAsync(string)
Section titled “SendCharacterAsync(string)”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.
TypeAsync(string, TypeOptions)
Section titled “TypeAsync(string, TypeOptions)”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).
UpAsync(string)
Section titled “UpAsync(string)”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.
Made with love by Dario Kondratiuk