Keyboard.press() 方法
¥Keyboard.press() method
Keyboard.down() 和 Keyboard.up() 的快捷方式。
¥Shortcut for Keyboard.down() and Keyboard.up().
签名
¥Signature
class Keyboard {
abstract press(
key: KeyInput,
options?: Readonly<KeyPressOptions>,
): Promise<void>;
}
参数
¥Parameters
范围 | 类型 | 描述 |
---|---|---|
key | 要按下的键的名称,例如 | |
options | 只读<KeyPressOptions> | (可选的)选项的对象。接受文本,如果指定,则使用该文本生成输入事件。接受延迟,如果指定,则为 |
Returns:
Promise<void>
备注
¥Remarks
如果 key
是单个字符,并且除了 Shift
之外没有按下任何修改键,也会生成 keypress
/input
事件。可以指定 text
选项来强制生成输入事件。
¥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.
修饰键 DO 效果 Keyboard.press()。按住 Shift
将以大写形式键入文本。
¥Modifier keys DO effect Keyboard.press(). Holding down Shift
will type the text in upper case.