tencent cloud

Feedback

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)
    }
    })
    
    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 avaliable.

    7x24 Phone Support