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, and this page is available as Markdown at /apps-plugin/docs/js-api/ui/input/onKeyboardHeightChange.md.

onKeyboardHeightChange

监听键盘高度变化事件。

扫码预览

扫码预览 onKeyboardHeightChange

支持版本

前端库版本不低于 0.0.20。

支持平台

平台支持情况
Android支持
iOS支持
PC不支持
HarmonyOS不支持

支持场景

场景支持情况
页面支持
卡片不支持

使用说明

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

调用方式

事件监听 API

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

入参

无。

调用示例

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

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

回调参数

名称类型必返说明
event.heightnumber是键盘高度,Android SDK 0.5.0 起单位为 dp,此前为 px;iOS 单位为 pt(points)。

返回值

返回 () => void。

回调示例

{
  "height": 336
}

平台差异

  • Android:Android SDK 0.5.0 起高度单位为 dp(密度无关像素),此前版本为 px(物理像素)。
  • iOS:高度单位为 pt(points)。