npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-keyboard

v1.0.0

Published

Customize Android/IOS soft keyboard

Downloads

1

Readme

rn-keyboard

This module shall provide you:

  • [x] Customize Android/IOS soft keyboard by using React Native Component on both Android & IOS.

    • [x] On Android, we run a parallel activity & hide the default keyboard away.
    • [x] On IOS, we replace the default keyboard view with your custom keyboard view.
  • [x] Custom Android Keyboard now show front of your modal. (Click here to see the discussion)

  • [x] Deal with the flickering issue of Android Keyboard.

Prerequisites

The specific React Native version must be satisfied to make your custom keyboard show up on Android & IOS.

  • react-native >= 0.64.0

Installation

yarn add rn-keyboard

Result

Android (Nexus 9)

Android screenshot

IOS (IPhone 11, IOS 15.4)

Ios screenshot

Usage

Please add those lines to your index.js at root folder:

// index.js (root folder)

...
import RnKeyboard from 'rn-keyboard'; // <-- Import here

RnKeyboard.registerComponent(); // <-- Add this line
AppRegistry.registerComponent(appName, () => App);

Then, please register your keyboard at root App component:

// App.js (root container)
...
import RnKeyboard from 'rn-keyboard'; // <-- Import here
import CustomKeyboard from 'path/to/your/custom/keyboard/in/your/project';

const App = () => {
    React.useEffect(() => {
        RnKeyboard.registerKeyboard("Your custom keyboard type", CustomKeyboard); // <-- Add this to your root container's componentDidMount
    }, []);

    return (
        <>
            ...
            {/* Add this to avoid keyboard */}
            <RnKeyboard.Spacer />
        </>
    )
}

Then, create your own keyboard:

// CustomKeyboard.tsx (this is just an example)
import * as React from 'react';
import {
  StyleSheet,
  TouchableOpacity,
  Text,
  View,
  Dimensions,
} from 'react-native';
import RnKeyboard from 'rn-keyboard';

const width = Dimensions.get('window').width;
const buttonList = (() => {
  const result: string[][] = [
    ['Backspace', '0', 'Enter'],
    ['1', '2', '3'],
    ['4', '5', '6'],
    ['7', '8', '9'],
  ];
  return result.map((row, rowIdx) => ({
    rowIdx,
    buttons: row.map((label) => ({ value: label, label })),
  }));
})();

const RnKeyboardNumeric = () => {
  const insert = (type: string) => async () => {
    try {
      const inputId = RnKeyboard.getFocusId();
      switch (type) {
        case 'Backspace':
          await RnKeyboard.backspace(inputId);
          return;

        case 'Enter':
          await RnKeyboard.submit(inputId);
          return;

        default:
          await RnKeyboard.insert(inputId, type);
      }
    } catch (err) {
      /** @todo handle error here */
    }
  };

  return (
    <View style={styles.container}>
      {buttonList.map((row) => (
        <View key={`row-${row.rowIdx}`}>
          {row.buttons.map((button) => (
            <TouchableOpacity
              activeOpacity={0.9}
              onPress={insert(button.value)}
              key={`button-${row.rowIdx}-${button.value}`}
            >
              <Text>{button.label}</Text>
            </TouchableOpacity>
          ))}
        </View>
      ))}
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#bdc3c7',
    paddingVertical: 16,
  },
});

Finally, you use our custom input in your custom screen to see your Keyboard show up:

// In your custom screen
...

const CustomScreen = () => {
  return (
    <>
        <RnKeyboard.Input
            rnKeyboardType={"Your registered custom keyboard type from App.js"}
            ... // TextInput props go here
        />
    </>
  );
};

Contributing

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

License

MIT