---
name: "onKeyboardWillShow"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "3.6.6" }
  - { name: "@ray-js/ray", version: "1.5.30" }
platform:
  - "iOS"
  - "Android"
async: true
title: "onKeyboardWillShow - 键盘弹出"
---

## onKeyboardWillShow

> [VERSION] BaseKit >= 3.6.6 | @ray-js/ray >= 1.5.30

> [PLATFORM] iOS, Android

> ⚡ **支持 Promise 调用** — 不传 success / fail / complete 回调时，该方法返回 Promise。

### 描述

键盘弹出

### 参数

`(listener: Function)`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `listener` | `(params: KeyboardBeanRes) => void` | 是 | - |  |

### 引用对象

##### `interface` KeyboardBeanRes

| 属性 | 类型 | 最低版本 | 描述 |
| --- | --- | --- | --- |
| `height` | `number` | `3.6.1` | 键盘高度 |
| `keyBoardArea` | `KeyBoardArea` | `3.32.6` | 键盘弹出位置 |

##### `interface` KeyBoardArea

| 属性 | 类型 | 最低版本 | 描述 |
| --- | --- | --- | --- |
| `top` | `number` | `3.32.6` | 键盘弹出顶部位置 |
| `bottom` | `number` | `3.32.6` | 键盘弹出底部位置 |
| `left` | `number` | `3.32.6` | 键盘左边位置 |
| `right` | `number` | `3.32.6` | 键盘右边位置 |


### 示例代码

#### Demo

```tsx
import { onKeyboardWillShow, scanCode } from '@ray-js/ray'

// 注册键盘弹出事件 + 用 scanCode 的键盘输入模式拉起系统键盘。
// scanCode 传 isShowKeyboard:true 会在扫码页提供“键盘输入”入口，进入后输入框自动聚焦弹出系统键盘，触发 onKeyboardWillShow。
onKeyboardWillShow(e => {
  console.log("[onKeyboardWillShow]", e);
});

scanCode({
  onlyFromCamera: false,
  isShowKeyboard: true,
  keyboardBean: { title: "键盘输入" },
  success: data => {
    console.log(data);
  },
  fail: error => {
    console.error(error);
  },
});
```
