cordova-plugin-ionic-keyboard
This plugin has been designed to work seamlessly with cordova-plugin-ionic-webview
, so make sure you have it installed first:
- https://github.com/ionic-team/cordova-plugin-ionic-webview
- https://ionicframework.com/docs/wkwebview/
Installation
cordova plugin add cordova-plugin-ionic-keyboard --save
Preferences
KeyboardResize (for iOS only)
Boolean (true by default)
Possible values
true
: Showing/hiding the keyboard will trigger some kind of resizing of the app (see KeyboardResizeMode)false
: Web will not be resized when the keyboard shows up.
KeyboardResizeMode (for iOS only)
String ('native' by default)
Possible values
native
: The whole native webview will be resized when the keyboard shows/hides, it will affect thevh
relative unit.body
: Only the html<body>
element will be resized. Relative units are not affected, because the viewport does not change.ionic
: Only the htmlion-app
element will be resized. Only for ionic apps.
KeyboardStyle (for iOS only)
String ('light' by default)
Possible values
light
dark
HideKeyboardFormAccessoryBar (for iOS only)
Boolean (true by default)
Possible values
true
: hides the keyboard accessory bar.false
: shows the keyboard accessory bar.
resizeOnFullScreen (for Android only)
There is an Android bug that prevents the keyboard from resizing the WebView when the app is in full screen (i.e. if StatusBar plugin is used to hide the StatusBar). This setting, if set to true, add a workaround that resizes the WebView even when the app is in full screen.
Boolean (false by default)
Possible values
false
: doesn't resize the WebView when the app is in full screen.true
: resizes the WebView when the app is in full screen.
Methods
Keyboard.hideFormAccessoryBar (for iOS only)
Hide the keyboard toolbar.
Set to true to hide the additional toolbar that is on top of the keyboard. This toolbar features the Prev, Next, and Done buttons.
Keyboard;
Quick Example
Keyboard;Keyboard;Keyboard;
Keyboard.hide
Hide the keyboard
Call this method to hide the keyboard
Keyboard;
Keyboard.show (for Android only)
Show the keyboard
Call this method to show the keyboard.
Keyboard;
Keyboard.setResizeMode (for iOS only)
Programmatically set the resize mode
Call the method with parameter to set the resize mode.
// Possible values are the same as for 'KeyboardResizeMode' preferenceKeyboard;Keyboard;Keyboard;
Keyboard.setKeyboardStyle (for iOS only)
Programmatically set the keyboard style
// Possible values are the same as for 'KeyboardStyle' preferenceKeyboard; // <- defaultKeyboard;
Keyboard.disableScroll (for iOS only)
Programmatically enable or disable the WebView scroll
Keyboard; // <- defaultKeyboard;
Properties
Keyboard.isVisible
Determine if the keyboard is visible.
Read this property to determine if the keyboard is visible.
if KeyboardisVisible // do something
Events
keyboardDidHide
This event is fired when the keyboard is fully closed.
Attach handler to this event to be able to receive notification when keyboard is closed.
window;
keyboardDidShow
This event is fired when the keyboard is fully open.
Attach handler to this event to be able to receive notification when keyboard is opened.
window;
keyboardWillShow
This event fires before keyboard will be shown.
Attach handler to this event to be able to receive notification when keyboard is about to be shown on the screen.
window;
keyboardWillHide
This event fires before keyboard will be closed.
Attach handler to this event to be able to receive notification when keyboard is about to be closed.
window;