mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
feat(puppeteer-core): keydown supports commands (#9357)
Issue: #1313 <!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. --> **What kind of change does this PR introduce?** Feature. **Did you add tests for your changes?** Yes. **If relevant, did you update the documentation?** Yes. **Summary** Supports keyboard shotcuts on MacOS. See Chrome Devtools Protocol document: https://chromedevtools.github.io/devtools-protocol/tot/Input/#method-dispatchKeyEvent.
This commit is contained in:
@@ -14,6 +14,7 @@ class Keyboard {
|
||||
key: KeyInput,
|
||||
options?: {
|
||||
text?: string;
|
||||
commands?: string[];
|
||||
}
|
||||
): Promise<void>;
|
||||
}
|
||||
@@ -21,10 +22,10 @@ class Keyboard {
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
||||
| key | [KeyInput](./puppeteer.keyinput.md) | Name of key to press, such as <code>ArrowLeft</code>. See [KeyInput](./puppeteer.keyinput.md) for a list of all key names. |
|
||||
| options | { text?: string; } | <i>(Optional)</i> An object of options. Accepts text which, if specified, generates an input event with this text. |
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| key | [KeyInput](./puppeteer.keyinput.md) | Name of key to press, such as <code>ArrowLeft</code>. See [KeyInput](./puppeteer.keyinput.md) for a list of all key names. |
|
||||
| options | { text?: string; commands?: string\[\]; } | <i>(Optional)</i> An object of options. Accepts text which, if specified, generates an input event with this text. Accepts commands which, if specified, is the commands of keyboard shortcuts, see [Chromium Source Code](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h) for valid command names. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ class Keyboard {
|
||||
options?: {
|
||||
delay?: number;
|
||||
text?: string;
|
||||
commands?: string[];
|
||||
}
|
||||
): Promise<void>;
|
||||
}
|
||||
@@ -22,10 +23,10 @@ class Keyboard {
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| key | [KeyInput](./puppeteer.keyinput.md) | Name of key to press, such as <code>ArrowLeft</code>. See [KeyInput](./puppeteer.keyinput.md) for a list of all key names. |
|
||||
| options | { delay?: number; text?: string; } | <i>(Optional)</i> An object of options. Accepts text which, if specified, generates an input event with this text. Accepts delay which, if specified, is the time to wait between <code>keydown</code> and <code>keyup</code> in milliseconds. Defaults to 0. |
|
||||
| Parameter | Type | Description |
|
||||
| --------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| key | [KeyInput](./puppeteer.keyinput.md) | Name of key to press, such as <code>ArrowLeft</code>. See [KeyInput](./puppeteer.keyinput.md) for a list of all key names. |
|
||||
| options | { delay?: number; text?: string; commands?: string\[\]; } | <i>(Optional)</i> An object of options. Accepts text which, if specified, generates an input event with this text. Accepts delay which, if specified, is the time to wait between <code>keydown</code> and <code>keyup</code> in milliseconds. Defaults to 0. Accepts commands which, if specified, is the commands of keyboard shortcuts, see [Chromium Source Code](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/editing/commands/editor_command_names.h) for valid command names. |
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user