The
Keyboard
object provides some functions to customize the iOS keyboard.
This plugin has only been tested in Cordova 3.2 or greater, and its use in previous Cordova versions is not recommended (potential conflict with keyboard customization code present in the core in previous Cordova versions).
If you do use this plugin in an older Cordova version (again, not recommended), you have to make sure the HideKeyboardFormAccessoryBar and KeyboardShrinksView preference values are always false, and only use the API functions to turn things on/off.
This plugin supports the HideKeyboardFormAccessoryBar (boolean) and KeyboardShrinksView (boolean) preferences in config.xml.
- Keyboard.shrinkView
- Keyboard.hideFormAccessoryBar
- Keyboard.disableScrollingInShrinkView
- Keyboard.isVisible
- Keyboard.onshow
- Keyboard.onhide
- Keyboard.onshowing
- Keyboard.onhiding
<feature name="Keyboard">
<param name="ios-package" value="CDVKeyboard" onload="true" />
</feature>
Shrink the WebView when the keyboard comes up.
Keyboard.shrinkView(true);
Set to true to shrink the WebView when the keyboard comes up. The WebView shrinks instead of the viewport shrinking and the page scrollable. This applies to apps that position their elements relative to the bottom of the WebView. This is the default behaviour on Android, and makes a lot of sense when building apps as opposed to webpages.
- iOS
Keyboard.shrinkView(true);
Keyboard.shrinkView(false);
Hide the keyboard toolbar.
Keyboard.hideFormAccessoryBar(true);
Set to true to hide the additional toolbar that is on top of the keyboard. This toolbar features the Prev, Next, and Done buttons.
- iOS
Keyboard.hideFormAccessoryBar(true);
Keyboard.hideFormAccessoryBar(false);
Disable scrolling when the the WebView is shrunk.
Keyboard.disableScrollingInShrinkView(true);
Set to true to disable scrolling when the WebView is shrunk.
- iOS
Keyboard.disableScrollingInShrinkView(true);
Keyboard.disableScrollingInShrinkView(false);
Determine if the keyboard is visible.
if (Keyboard.isVisible) {
// do something
}
Read this property to determine if the keyboard is visible.
- iOS
Specifies whenether content of page would be autoamtically scrolled to the top of the page when keyboard is hiding.
Keyboard.automaticScrollToTopOnHiding = true;
Set this to true if you need that page scroll to beginning when keyboard is hiding. This is allows to fix issue with elements declared with position: fixed, after keyboard is hiding.
- iOS
If defined, this function fired when keyboard fully shown.
Keyboard.onshow = function () {
// Describe your logic which will be run each time keyboard is shown.
}
Attach handler to this event to be able to receive notification when keyboard is shown.
- iOS
If defined, this function fired when keyboard fully closed.
Keyboard.onhide = function () {
// Describe your logic which will be run each time keyboard is closed.
}
Attach handler to this event to be able to receive notification when keyboard is closed.
- iOS
If defined, this function fired before keyboard will be shown.
Keyboard.onshowing = function () {
// Describe your logic which will be run each time when keyboard is about to be shown.
}
Attach handler to this event to be able to receive notification when keyboard is about to be shown on the screen.
- iOS
If defined, this function fired when keyboard fully closed.
Keyboard.onhiding = function () {
// Describe your logic which will be run each time when keyboard is about to be closed.
}
Attach handler to this event to be able to receive notification when keyboard is about to be closed.
- iOS