Coder Social home page Coder Social logo

brianush1 / cordova-plugin-ionic-keyboard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ionic-team/cordova-plugin-ionic-keyboard

0.0 0.0 0.0 246 KB

Keyboard Plugin for Cordova

License: Other

JavaScript 19.55% Objective-C 51.44% Java 29.01%

cordova-plugin-ionic-keyboard's Introduction

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:

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.
<preference name="KeyboardResize" value="true" />

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 the vh 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 html ion-app element will be resized. Only for ionic apps.
<preference name="KeyboardResizeMode" value="native" />

KeyboardStyle (for iOS only)

String ('light' by default)

Possible values

  • light
  • dark
<preference name="KeyboardStyle" value="dark" />

HideKeyboardFormAccessoryBar (for iOS only)

Boolean (true by default)

Possible values

  • true: hides the keyboard accessory bar.
  • false: shows the keyboard accessory bar.
<preference name="HideKeyboardFormAccessoryBar" value="false" />

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.
<preference name="resizeOnFullScreen" value="true" />

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.hideFormAccessoryBar(value, successCallback);

Quick Example

Keyboard.hideFormAccessoryBar(true);
Keyboard.hideFormAccessoryBar(false);
Keyboard.hideFormAccessoryBar(null, (currentValue) => { console.log(currentValue); });

Keyboard.hide

Hide the keyboard

Call this method to hide the keyboard

Keyboard.hide();

Keyboard.show (for Android only)

Show the keyboard

Call this method to show the keyboard.

Keyboard.show();

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' preference
Keyboard.setResizeMode('native');
Keyboard.setResizeMode('body');
Keyboard.setResizeMode('ionic');

Keyboard.setKeyboardStyle (for iOS only)

Programmatically set the keyboard style

// Possible values are the same as for 'KeyboardStyle' preference
Keyboard.setKeyboardStyle('light'); // <- default
Keyboard.setKeyboardStyle('dark');

Keyboard.disableScroll (for iOS only)

Programmatically enable or disable the WebView scroll

Keyboard.disableScroll(true); // <- default
Keyboard.disableScroll(false);

Properties

Keyboard.isVisible

Determine if the keyboard is visible.

Read this property to determine if the keyboard is visible.

if (Keyboard.isVisible) {
    // 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.addEventListener('keyboardDidHide', () => {
    // Describe your logic which will be run each time keyboard is closed.
});

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.addEventListener('keyboardDidShow', (event) => {
    // Describe your logic which will be run each time when keyboard is about to be shown.
    console.log(event.keyboardHeight);
});

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.addEventListener('keyboardWillShow', (event) => {
    // Describe your logic which will be run each time when keyboard is about to be shown.
    console.log(event.keyboardHeight);
});

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.addEventListener('keyboardWillHide', () => {
    // Describe your logic which will be run each time when keyboard is about to be closed.
});

cordova-plugin-ionic-keyboard's People

Contributors

agrieve avatar ashearer avatar brad avatar ccorcos avatar cjpearson avatar dolgachio avatar dpogue avatar dylanvdmerwe avatar fmgasparino avatar gconnolly avatar hideov avatar jcesarmobile avatar kant2002 avatar manucorporat avatar mbackschat avatar mhartington avatar mlynch avatar mmocny avatar rahulbpatel avatar sfaizanh avatar shazron avatar spartanace1024 avatar themattray avatar xland avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.