nativescript-na-keyboard
A NativeScript keyboard observer
npm i --save nativescript-na-keyboard
  • Version: 1.1.0
  • GitHub:
  • Downloads:
    • Last Day:   3
    • Last Week:  8
    • Last Month: 33

NativeScript NA Keyboard plugin

NOTE! Android is currently not supported.

A NativeScript keyboard observer that utilizes KWKeyboardListener for iOS.

Installation

$ tns plugin add nativescript-na-keyboard

Usage

Simply require the plugin and do as such:

var NAKeyboard = require("nativescript-na-keyboard");

NAKeyboard.on("open close", function(eventData) {
console.log(eventData.eventName); // Returns either "open" or "close".
console.dump(eventData.keyboardFrame); // Returns position and size of the keyboard.
});

Methods

on()

To observe keyboard activity.

on(eventTypes, callback)

  • eventTypes - Can be either "open" or "close". If both, separate them with a blankspace (i.e. "open close").
  • callback - The callback function. Available parameter is "eventData" which is an object that includes eventName and keyboardFrame.

setAvoidingView()

Set a view that the keyboard should avoid.

setAvoidingView(view)

  • view - The view that should be pulled when the keyboard opens.
var view = page.getViewById("inputText"); // The TextField view
NAKeyboard.setAvoidingView(view);

Other methods

  • keyboardVisible() - Returns true or false depending on keyboard's current state.

Known issues

  • No Android compatibility, yet.

History

Version 1.1.0 (22 October 2016)

  • Added two new methods: keyboardVisible() and setAvoidingView().

Version 1.0.1 (18 October 2016)

  • Added to npm.

Version 1.0.0 (18 October 2016)

  • on() method for observing keyboard activity.

Credits

License

MIT - for {N} version 2.0.0+