Keyboard
updateKeyboard
TIP
The API usage is as follows: wx.updateKeyboard(Object object)
- Functional description: Update the content of the keyboard input box. It will only take effect when the keyboard is pulled up.
- Parameters and descriptions: Object object。
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| value | string | - | Yes | Current value of the keyboard input box |
| 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) |
showKeyboard
TIP
The API usage is as follows: wx.showKeyboard(Object object)
- Functional description: Show the keyboard.
- Parameters and descriptions: Object object。
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| defaultValue | string | - | Yes | Default value displayed in the keyboard input box |
| maxLength | number | - | Yes | Maximum length of text in the keyboard |
| multiple | boolean | - | Yes | Is it multi-line input |
| confirmHold | boolean | - | Yes | Whether the keyboard remains displayed when clicking Done |
| confirmType | string | - | Yes | The type of the confirm button in the lower right corner of the keyboard, which only affects the text content of the button |
| 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) |
confirmType Legal value
Legal value Description done Done next Next search Search go Go send Send
onKeyboardInput
TIP
The API usage is as follows: wx.onKeyboardInput(function listener)
Functional description: Listen for keyboard input events.
Parameters and descriptions: function listener, Listen for keyboard input events, parameters are as follows:
Properties Type Description value string Current value of keyboard input
onKeyboardHeightChange
TIP
The API usage is as follows: wx.onKeyboardHeightChange(function listener)
Functional description: Listen for keyboard height change events.
Parameters and descriptions: function listener, Listen for keyboard height change events, parameters are as follows:
Object res。
Properties Type Description height number Keyboard height Sample code:
wx.onKeyboardHeightChange((res) => {
console.log(res.height);
});onKeyboardConfirm
TIP
The API usage is as follows: wx.onKeyboardConfirm(function listener)
Functional description: Listen for events when the user clicks the Confirm button on the keyboard.
Parameters and descriptions: function listener, Listen for events when the user clicks the Confirm button on the keyboard, parameters are as follows:
Properties Type Description value string Current value of keyboard input
onKeyboardComplete
TIP
The API usage is as follows: wx.onKeyboardComplete(function listener)
Functional description: Listen for keyboard retraction events.
Parameters and descriptions: function listener, Listen for keyboard retraction events, parameters are as follows:
Properties Type Description value string Current value of keyboard input
offKeyboardInput
TIP
The API usage is as follows: wx.offKeyboardInput(function listener)
- Functional description: Remove the listener for keyboard input events.
- Parameters and descriptions: function listener, Listener function passed in by onKeyboardInput. If this parameter is not passed, all listeners are removed.
- Sample code:
const listener = function (res) {
console.log(res);
};
wx.onKeyboardInput(listener);
d;
wx.offKeyboardInput(listener); // Must pass the same function object used in onKeyboardInputoffKeyboardHeightChange
TIP
The API usage is as follows: wx.offKeyboardHeightChange(function listener)
- Functional description: Remove the listener for keyboard height change events.
- Parameters and descriptions: function listener, Listener function passed in by onKeyboardHeightChange. If this parameter is not passed, all listeners are removed.
- Sample code:
const listener = function (res) {
console.log(res);
};
wx.onKeyboardHeightChange(listener);
wx.offKeyboardHeightChange(listener); // Must pass the same function object used in onKeyboardHeightChangeoffKeyboardConfirm
TIP
The API usage is as follows: wx.offKeyboardConfirm(function listener)
- Functional description: Remove the listener for events when the user clicks the Confirm button on the keyboard.
- Parameters and descriptions: function listener, Listener function passed in by onKeyboardConfirm. If this parameter is not passed, all listeners are removed.
- Sample code:
const listener = function (res) {
console.log(res);
};
wx.onKeyboardConfirm(listener);
wx.offKeyboardConfirm(listener); // Must pass the same function object used in onKeyboardConfirmoffKeyboardComplete
TIP
The API usage is as follows: wx.offKeyboardComplete(function listener)
- Functional description: Remove the listener for events when the keyboard is retracted.
- Parameters and descriptions: function listener, Listener function passed in by onKeyboardComplete. If this parameter is not passed, all listening functions will be removed.
- Sample code:
const listener = function (res) {
console.log(res);
};
wx.onKeyboardComplete(listener);
wx.offKeyboardComplete(listener); // Must pass the same function object used in onKeyboardCompletehideKeyboard
TIP
The API usage is as follows: wx.hideKeyboard(Object object)
Functional description: Hide 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);
},
});