tencent cloud

All product documents
Tencent Cloud Super App as a Service
Keyboard
Last updated: 2024-11-21 18:48:11
Keyboard
Last updated: 2024-11-21 18:48:11

onKeyboardHeightChange

This API is used via wx.onKeyboardHeightChange(function listener)
Feature Description: Listen for keyboard height change events.
Parameter and Description: function callback, listener for keyboard height change events.
Listener function parameter: Object res.
Attribute
Type
Description
height
number
Keyboard Height
Sample Code
wx.onKeyboardHeightChange(res => {
console.log(res.height)
})

hideKeyboard

This API is used via wx.hideKeyboard(Object object).
Feature Description: Call this interface manually to retract the keyboard after it has been pulled up by the input, textarea, etc. focus.
Parameter and Description: Object.
Attribute
Type
Default value
Required
Description
success
function
-
No
Callback Function of Successful Interface Call
fail
function
-
No
Callback Function of Failing Interface Call
complete
function
-
No
Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
Sample Code
wx.hideKeyboard({
complete: res => {
console.log('hideKeyboard res', res)
}
})

offKeyboardHeightChange

This API is used via wx.offKeyboardHeightChange(function listener).
Feature Description: Removes the listener function for keyboard height change events.
Parameter and Description: function listener, the listener function passed in by onKeyboardHeightChange. If this parameter is not passed in, all listener functions will be removed.
Sample Code
const listener = function (res) { console.log(res) }

wx.onKeyboardHeightChange(listener)
wx.offKeyboardHeightChange(listener) // The same function object as the listener must be passed in.

getSelectTextRange

This API is used via wx.getSelectedTextRange(Object object).
Feature Description: After input, textarea, etc. are focused, the cursor position in the input box is obtained. This interface is only effective when called during focus.
Parameter and Description: Object.
Attribute
Type
Default value
Required
Description
success
function
-
No
Callback Function of Successful Interface Call
fail
function
-
No
Callback Function of Failing Interface Call
complete
function
-
No
Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
Object.success callback function: Object res.
Attribute
Type
Description
start
number
Initial cursor position in the input field
end
number
Final cursor position in the input field
Sample Code
wx.getSelectedTextRange({
complete: res => {
console.log('getSelectedTextRange res', res.start, res.end)
}
})

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon