Class Keyboard
- Namespace
- PuppeteerSharp.Input
- 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 abstract class Keyboard : IKeyboard
- Inheritance
-
Keyboard
- Implements
- Derived
Methods
DownAsync(string, DownOptions)
Dispatches a keydown
event.
public abstract Task DownAsync(string key, DownOptions options = null)
Parameters
key
stringName of key to press, such as
ArrowLeft
. KeyDefinitions for a list of all key names.options
DownOptionsdown 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)
Shortcut for DownAsync(string, DownOptions) and UpAsync(string).
public abstract Task PressAsync(string key, PressOptions options = null)
Parameters
key
stringName of key to press, such as
ArrowLeft
. KeyDefinitions for a list of all key names.options
PressOptionspress 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 abstract Task SendCharacterAsync(string charText)
Parameters
charText
stringCharacter 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 abstract Task TypeAsync(string text, TypeOptions options = null)
Parameters
text
stringA text to type into a focused element.
options
TypeOptionstype 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 abstract Task UpAsync(string key)
Parameters
key
stringName of key to release, such as
ArrowLeft
. See KeyDefinitions for a list of all key names.
Returns
- Task
Task.