Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-easy-keyboard

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-easy-keyboard

A simple way to create virtual keyboards

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

react-native-easy-keyboard

A simple way to create virtual keyboards for React Native

Installation

Install the package with npm

npm i --save react-native-easy-keyboard

or with yarn

yarn add react-native-easy-keyboard

How do I change the layout of my keyboard?

react-native-easy-keyboard layouts are made up of lists of strings or KeyConfig objects representing each row of the keyboard.

With strings

import EasyKeyboard, {KeyboardConfig} from 'react-native-easy-keyboard';

const myCustomLayout: KeyboardConfig = {
  layouts: {
    default: [
      ['7', '8', '9'],
      ['4', '5', '6'],
      ['1', '2', '3'],
    ],
  },
};

return <EasyKeyboard config={myCustomLayout} />;

With KeyConfig objects

import EasyKeyboard, {KeyboardConfig} from 'react-native-easy-keyboard';

const myCustomLayout: KeyboardConfig = {
  layouts: {
    default: [
      [{value: '7'}, {value: '8'}, {value: '9'}],
      [{value: '4'}, {value: '5'}, {value: '6'}],
      [{value: '1'}, {value: '2'}, {value: '3'}],
    ],
  },
};

<EasyKeyboard config={myCustomLayout} />;

They can also be mixed

import EasyKeyboard, {KeyboardConfig} from 'react-native-easy-keyboard';

const myCustomLayout: KeyboardConfig = {
  layouts: {
    default: [
      ['7', {value: '8'}, '9'],
      [{value: '4'}, '5', {value: '6'}],
      ['1', {value: '2'}, '3'],
    ],
  },
};

<EasyKeyboard config={myCustomLayout} />;

How do I change the size of my keys?

To change the size of a key you can either use the size property of the KeyConfig object or end your string with a pair of curly brackets containing the desired size.

The "8" key in these examples will be the width of 3 default size keys

With strings

import EasyKeyboard, {KeyboardConfig} from 'react-native-easy-keyboard';

const myCustomLayout: KeyboardConfig = {
  layouts: {
    default: [['7', '8{3}', '9']],
  },
};

return <EasyKeyboard config={myCustomLayout} />;

With KeyConfig objects

import EasyKeyboard, {KeyboardConfig} from 'react-native-easy-keyboard';

const myCustomLayout: KeyboardConfig = {
  layouts: {
    default: [[{value: '7'}, {value: '8', size: 3}, {value: '9'}]],
  },
};

<EasyKeyboard config={myCustomLayout} />;

How do I change the style of my keyboard?

import EasyKeyboard, {KeyboardTheme} from 'react-native-easy-keyboard';

const myTheme: KeyboardTheme = {
  containerStyle: {
    alignItems: 'center',
    justifyContent: 'flex-end',
  },
  rowStyle: {},
  keyStyle: {},
  textStyle: {},
};

<EasyKeyboard theme={myTheme} />;

How do I change the text on a key?

To change the text displayed on a key you can either configure the displayOptions in the KeyboardConfig, (this will affect all keys in every layout) or you can use the display option in the KeyConfig object.

With displayOptions

import EasyKeyboard, {KeyboardConfig} from 'react-native-easy-keyboard';

const myCustomLayout: KeyboardConfig = {
  layouts: {
    default: [['7', '8', '9', '{del}']],
  },
  displayOptions: {
    display: {
      '{del}': '<- Delete',
      '9': 'Nine',
    },
  },
};

<EasyKeyboard config={myCustomLayout} />;

With KeyConfig

import EasyKeyboard, {KeyboardConfig} from 'react-native-easy-keyboard';

const myCustomLayout: KeyboardConfig = {
  layouts: {
    default: [
      [
        '7',
        '8',
        {value: '9', display: 'Nine'},
        {value: '{del}', display: '<- Delete'},
      ],
    ],
  },
};

<EasyKeyboard config={myCustomLayout} />;

KeyboardTheme

PropertyTypeNotes
keyStyleViewStyleThe style applied to TouchableOpacity for each key
textStyleTextStyleThe style applied to the Text for each key
rowStyleViewStyleThe style applied to to View containing each row
containerStyleViewStyleThe style applied to the main View containing the keyboard

KeyConfig

PropertyTypeNotes
valuestringThe value that will be returned when the key is pressed (Required)
sizenumberThe size of the key. 2 = double the size of a normal key, 0.5 = half the size of a normal key. Only affects the width of the key (Default 1)
isTriggerbooleanIf the key should trigger the onTriggerPressed callback (Default false)
displaystringThe text to be displayed on the key. If undefined value property is used instead
keyStyleViewStyleStyle for the keys TouchableOpacity component
textStyleTextStyleStyle for the keys Text component

KeyboardConfig

EasyKeyboard Component

Methods

Method nameArgumentsNotes
setKeyboardLayoutlayoutName: stringChanges the layout of the keyboard if the layout exists in the config

Props

PropTypeRequiredNote
configKeyboardConfigtrueThe configuration for the keyboard, containing all the layouts
themeKeyboardThemefalse

Events

Event NameReturnsNotes
onKeyPresskey: stringCallback that is called when a key is pressed
onTriggerPresstrigger: stringCallback that is called when a trigger key is pressed

Keywords

FAQs

Package last updated on 09 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc