Keyboard
onKeyboardHeightChange
TIP
The API usage is as follows: wx.onKeyboardHeightChange(function listener)
Functional description: Listen for keyboard height change events
Parameters and descriptions: function callback,Listener function for keyboard height change events
object.success callback function parameters: Object res。
Properties Type Description height number Keyboard height Sample code:
wx.onKeyboardHeightChange(res => {
console.log(res.height)
})hideKeyboard
TIP
The API usage is as follows: wx.hideKeyboard(Object object)
Functional description: After the input, textarea, etc. are focused and the keyboard is pulled up, manually call this interface to close the keyboard
Parameters and descriptions: Object object。
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) Sample code:
wx.hideKeyboard({
complete: res => {
console.log('hideKeyboard res', res)
}
})offKeyboardHeightChange
TIP
The API usage is as follows: wx.offKeyboardHeightChange(function listener)
Functional description: Remove listener function for keyboard height change events
Parameters and descriptions: function listener,The listening function passed in by onKeyboardHeightChange. If this parameter is not passed, all listening functions will be removed
Sample code:
const listener = function (res) { console.log(res) }
wx.onKeyboardHeightChange(listener)
wx.offKeyboardHeightChange(listener) // Pass the same function object used for listening.getSelectedTextRange
TIP
The API usage is as follows: wx.getSelectedTextRange(Object object)
Functional description: After the input, textarea, etc. are focused, get the cursor position of the input box Note: This interface is only valid when called when focused
Parameters and descriptions: Object object。
Properties Type Default value Required Description success Function - No Callback function for successful interface call fail Function - No Callback function for failed interface call complete Function - No Callback function for interface call completion (executed regardless of success or failure) object.success callback function parameters: Object res。
Properties Type Description start number The starting position of the input box cursor end number The ending position of the input box cursor Sample code:
wx.getSelectedTextRange({
complete: res => {
console.log('getSelectedTextRange res', res.start, res.end)
}
})