react-native-is-keyboard-connected
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

react-native-is-keyboard-connected

React Native library for checking whether a keyboard is connected The new and old architectures are supported!

Installation

  1. Download package with npm or yarn
npm i react-native-is-keyboard-connected
yarn add react-native-is-keyboard-connected
  1. Android only

Add to the MainActivity.java lines:

  //android/app/src/main/java/com/project-name/MainActivity.java

  ...
  import android.content.Intent;
  import android.content.res.Configuration;
  ...
  
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    Intent intent = new Intent("onConfigurationChanged");
    intent.putExtra("newConfig", newConfig);
    this.sendBroadcast(intent);
  }

  1. iOS only

Install pods

cd ios && pod install

Link keyboard(Game) binary with libraries

  • Open xcode
  • Select folder in the project bar
  • Select target project
  • Select Build Phases
  • Expand Link Binary With Libraries
  • Press plus icon
  • You can search for Game
  • Select GameController.framework, GameKit.framework, GameplayKit.framework

See screenshot below:

Usage

import { isKeyboardConnected, keyboardStatusListener, useIsKeyboardConnected } from 'react-native-is-keyboard-connected';

// ...

const isKeyboardConnected = useIsKeyboardConnected();


// Or you can handle it by your own
 
const removeListenerFn = keyboardStatusListener((e) => setResult(e.status));
isKeyboardConnected().then((isConnected) => setResult(isConnected));

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-is-keyboard-connected

Weekly Downloads

22

Version

0.1.2

License

MIT

Unpacked Size

61.6 kB

Total Files

33

Last publish

Collaborators

  • artur_kalach