---
description: "softKeyboardFunc softKeyboardFunc 软键盘弹起监听方法(ios)：监听移动端软键盘弹起的全局事件，用于处理软键盘遮挡相关问题"
category: browser-runtime
keywords: ["softKeyboardFunc", "eventEmitter", "软键盘弹起监听方法(ios)", "iOS软键盘", "输入法", "浏览器", "UA", "vconsole", "移动端", "软键盘", "运行环境"]
source: "https://www.e-cology.com.cn/utils/softKeyboardFunc/freepass"
---

# softKeyboardFunc softKeyboardFunc 软键盘弹起监听方法(ios)

## 适用场景

监听移动端软键盘弹起的全局事件，用于处理软键盘遮挡相关问题

## 检索符号

- `eventEmitter`
- `softKeyboardFunc`

## 代表示例

```js
import { eventEmitter } from '@weapp/utils';

componentDidMount() {
  eventEmitter.on('@weapp/utils', 'softKeyboardFocus', this.softKeyboardFocus)
  eventEmitter.on('@weapp/utils', 'softKeyboardScroll', this.softKeyboardScroll)
}

componentWillUnmount() {
  eventEmitter.off('@weapp/utils', 'softKeyboardFocus', this.softKeyboardFocus)
  eventEmitter.off('@weapp/utils', 'softKeyboardScroll', this.softKeyboardScroll)
}

softKeyboardFocus = (hasInputMethod, visualHeight, e) => {
  console.log(hasInputMethod, visualHeight, e)
}

softKeyboardScroll = (scrollY, e) => {
  console.log(scrollY, e)
}
```

## 深入阅读
- [在线免登文档](https://www.e-cology.com.cn/utils/softKeyboardFunc/freepass)

> 本卡用于快速选型。参数、返回值、限制和完整示例以原始文档为准。
