npm i --save nativescript-na-keyboard
- Version: 1.1.0
- GitHub:
- NPM: https://www.npmjs.com/package/nativescript-na-keyboard
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
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
andkeyboardFrame
.
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()
andsetAvoidingView()
.
Version 1.0.1 (18 October 2016)
- Added to npm.
Version 1.0.0 (18 October 2016)
on()
method for observing keyboard activity.
Credits
- NordlingArt
- kwarter (for providing KWKeyboardListener)
License
MIT - for {N} version 2.0.0+