# InputManager::GetButtonDown 查询一个具名逻辑按钮是否在本帧刚被按下。 ```cpp bool GetButtonDown(const Containers::String& buttonName) const; ``` ## 行为说明 当前实现把逻辑按钮当作 `KeyCode` 别名处理,这个方法的工作流程是: 1. 在 `m_buttons` 中查找 `buttonName` 2. 如果未注册,返回 `false` 3. 如果找到,则对映射后的键调用 [IsKeyPressed](IsKeyPressed.md) 这意味着它继承了 `IsKeyPressed()` 的全部语义: - 返回的是“本帧按下边沿”,不是持续按住态 - 依赖 [Update](Update.md) 的帧边界 - 当前不会过滤平台重复按键消息;如果映射键在后续帧收到 repeat keydown,本方法也可能再次返回 `true` ## 参数 - `buttonName` - 逻辑按钮名称。 ## 返回值 - `bool` - 该按钮是否在本帧刚被按下。 ## 示例 ```cpp if (XCEngine::Input::InputManager::Get().GetButtonDown("Fire1")) { // ... } ``` ## 相关文档 - [返回类型总览](InputManager.md) - [GetButton](GetButton.md) - [GetButtonUp](GetButtonUp.md) - [IsKeyPressed](IsKeyPressed.md)