1.0.4 • Published 5 years ago
the-keyboard v1.0.4
the-keyboard
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
Name | Type | Description | Default |
---|---|---|---|
keys | arrayOf array | Keys 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
Name | Type | Description | Default |
---|---|---|---|
options | object | Style options | {} |
License
This software is released under the MIT License.