> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/keyboard/key-press.md).

# 按键

Key press是模拟键盘操作的行为，允许您输入文本、按下单个键或在浏览器界面上激活快捷键组合。

#### 支持的按键类型 (Type):

该操作提供3种灵活的键盘交互机制：

1. Single key: 按下键盘上的单个键。
2. Combo key: 同时按下一个快捷键组合。
   * *支持的系统按键列表*: Alt, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Backspace, Cancel, Clear, Command, Control, Decimal, Delete, Divide, Down, End, Enter, Equal, Escape, F1到F12, Help, Home, Insert, Left, LeftAlt, LeftControl, LeftShift, Meta, Multiply, Null, NumberPad0到NumberPad9, PageDown, PageUp, Pause, Return, Right, Semicolon, Separator, Shift, Space, Subtract, Tab, Up, ZenkakuHankaku.
3. Text: 在输入框中输入或粘贴一段文本（字符字符串）。

#### 配置参数：

* KEY: 交互内容输入框。
  * 如果选择Text类型：输入您想要输入的文本段落。
  * 如果选择Single key或Combo key类型：准确输入支持列表中的按键名称。对于组合键，按键必须连写并用`+`连接（例如：`Control+A`选择全部，`Control+Shift+Delete`清除历史记录）。
* Xpath: 您想要交互的输入框（input, textarea）的标识符路径（XPath）。
  * *注意*: 如果您对整个浏览器使用`Single key`或`Combo key`类型，可以将此框留空。
* Delay each character: 输入文本时每个字符之间的延迟时间。具有以下特殊配置：
  * 0,0: 超高速输入，没有等待时间（0秒）。
  * -1: 系统将直接执行粘贴命令，将所有内容立即粘贴到输入框中，而不是逐个输入。
  * *强制注意*: 如果您的文本段落包含表情符号（Emoji），您必须将此项配置为`-1`以避免显示错误。

#### 实际示例：自动删除旧内容并输入新关键词

当您希望脚本自动清除Google搜索框中现有的字符，然后粘贴一个新关键词并按Enter进行搜索时：

1. 步骤1（点击搜索框）：使用命令\_Mouse click\_点击输入框。
2. 步骤2（全选旧字符）：拖动命令\_Key press\_ ➔ 选择Type: `Combo key` ➔ KEY: `Control+A` ➔ Xpath: 留空。
3. 步骤3（删除旧字符）：拖动命令\_Key press\_ ➔ 选择Type: `Single key` ➔ KEY: `Backspace` ➔ Xpath: 留空。
4. 步骤4（输入新内容并带有Emoji）：拖动命令\_Key press\_ ➔ 选择Type: `Text` ➔ KEY: `GPM Softwares 🚀` ➔ Delay each character: `-1`（以快速粘贴并识别火箭表情）➔ Xpath: 输入搜索框的XPath。
5. 步骤5（按Enter）：拖动命令\_Key press\_ ➔ 选择Type: `Single key` ➔ KEY: `Enter` ➔ Xpath: 留空。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/keyboard/key-press.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
