DedrisFrameworkDedrisFramework

← Plugins  /  Keyboard

⌨️

Keyboard

cordova-plugin-ionic-keyboard
iOS Android

Maintained by the Ionic team, this plugin gives you fine control over the on-screen keyboard: events that tell you when it shows or hides (and how tall it is), methods to dismiss it, and preferences that decide how your layout resizes around it.

Installation

terminal
cordova plugin add cordova-plugin-ionic-keyboard

Events

Add these listeners on window after deviceready:

EventFires when
keyboardWillShowJust before the keyboard appears; event.keyboardHeight gives its height.
keyboardDidShowAfter the keyboard is fully shown.
keyboardWillHideJust before the keyboard is dismissed.
keyboardDidHideAfter the keyboard has been dismissed.

Methods & properties

MemberDescription
Keyboard.hide()Dismiss the keyboard programmatically.
Keyboard.show()Show the keyboard (Android only).
Keyboard.isVisibleBoolean — whether the keyboard is currently shown.
Keyboard.setResizeMode(mode)How the web view resizes: native, body, ionic or none.

You can also set KeyboardResize, KeyboardResizeMode and KeyboardStyle as preferences in config.xml.

Usage example

Shift a floating button up while the keyboard is open:

www/js/app.js
window.addEventListener("keyboardWillShow", function (e) {
  document.body.style.setProperty("--kb", e.keyboardHeight + "px");
});

window.addEventListener("keyboardWillHide", function () {
  document.body.style.setProperty("--kb", "0px");
});

function dismiss() {
  Keyboard.hide();
}

Tips

📚 Source: the technical reference on this page is based on the cordova-plugin-ionic-keyboard project (MIT licensed), maintained by the Ionic team. Descriptions and examples have been rewritten in DedrisFramework's own words. This plugin is not part of the Apache Cordova core.
← Back to plugins Start a project