> For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt.

# onKeyboardHeightChange

监听键盘高度变化事件。

## 扫码预览

![扫码预览 onKeyboardHeightChange](https://api.qrserver.com/v1/create-qr-code/?size=200x200\&data=doubao%3A%2F%2Fdoubao_apps%3Fapp_id%3Ddb_1McM5Ni%26path%3D%252Fpages%252Fapi%252Fkeyboard%252Fon-keyboard-height-change%252Findex)

## 支持版本

前端库版本不低于 `0.0.20`。

## 支持平台

<table>
<thead>
<tr><th>平台</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>Android</td><td>支持</td></tr>
<tr><td>iOS</td><td>支持</td></tr>
<tr><td>PC</td><td>不支持</td></tr>
<tr><td>HarmonyOS</td><td>不支持</td></tr>
</tbody>
</table>

## 支持场景

<table>
<thead>
<tr><th>场景</th><th>支持情况</th></tr>
</thead>
<tbody>
<tr><td>页面</td><td>支持</td></tr>
<tr><td>卡片</td><td>不支持</td></tr>
</tbody>
</table>

## 使用说明

- 注册后返回取消监听函数，页面卸载前调用以避免重复回调。

## 调用方式

### 事件监听 API

```typescript
onKeyboardHeightChange(callback: (event: KeyboardHeightChangeEvent) => void): () => void
```

## 入参

无。

## 调用示例

```typescript
import { onKeyboardHeightChange } from '@doubao-dev/framework/api';

const unsubscribe = onKeyboardHeightChange(({ height }) => {
  console.log('Keyboard height change event:', { height });
});
```

## 回调参数

<table>
<thead>
<tr><th>名称</th><th>类型</th><th>必返</th><th>说明</th></tr>
</thead>
<tbody>
<tr><td><code>event.height</code></td><td><code>number</code></td><td>是</td><td>键盘高度，Android SDK 0.5.0 起单位为 dp，此前为 px；iOS 单位为 pt（points）。</td></tr>
</tbody>
</table>

## 返回值

返回 () => void。

### 回调示例

```json
{
  "height": 336
}
```

## 平台差异

- **Android**：Android SDK 0.5.0 起高度单位为 dp（密度无关像素），此前版本为 px（物理像素）。
- **iOS**：高度单位为 pt（points）。
