1.0.4 • Published 5 years ago

the-keyboard v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

the-keyboard

Build Status npm Version JS Standard

Keyboard component

Installation

$ npm install the-keyboard --save

Usage

'use strict'

import React from 'react'
import { TheKeyboard, TheKeyboardStyle } from 'the-keyboard'

class ExampleComponent extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      pressed: []
    }
  }

  handleKeyPress = (key) => {
    this.setState({
      pressed: [...this.state.pressed, key]
    })
  }

  render () {
    return (
      <div>
        <TheKeyboardStyle/>
        <div>{this.state.pressed.join('')}</div>
        <TheKeyboard keys={[
          [1, 2, 3],
          [4, 5, 6],
          [7, 8, 9],
          [null, 0, null],
        ]}
                     onKeyPress={this.handleKeyPress}
        />
      </div>

    )
  }
}

export default ExampleComponent

Components

TheKeyboard

Keyboard component

Props

NameTypeDescriptionDefault
keysarrayOf arrayKeys to show`[

1, 2, 3, 4, 5, 6, 7, 8, 9, null, 0, null, ]| |onKeyPress| func | Handle key press |() => null` |

TheKeyboardButton

TheKeyboardStyle

Style for TheKeyboard

Props

NameTypeDescriptionDefault
optionsobjectStyle options{}

License

This software is released under the MIT License.

Links