mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2026-04-30 00:00:04 +08:00
Improving readme
This commit is contained in:
@@ -119,6 +119,63 @@ theme={"hg-theme-default"}
|
|||||||
debug={false}
|
debug={false}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### newLineOnEnter
|
||||||
|
|
||||||
|
> Specifies whether clicking the "ENTER" button will input a newline (`\n`) or not.
|
||||||
|
|
||||||
|
```js
|
||||||
|
newLineOnEnter={true}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Methods
|
||||||
|
|
||||||
|
simple-keybord has a few methods you can use to further control it's behavior.
|
||||||
|
To access these functions, you need a `ref` of the simple-keyboard component, like so:
|
||||||
|
|
||||||
|
```js
|
||||||
|
<Keyboard
|
||||||
|
ref={r => this.keyboard = r}
|
||||||
|
[...]
|
||||||
|
/>
|
||||||
|
|
||||||
|
// Then, on componentDidMount ..
|
||||||
|
this.keyboard.methodName(params);
|
||||||
|
```
|
||||||
|
|
||||||
|
### clearInput
|
||||||
|
|
||||||
|
> Clear the keyboard's input.
|
||||||
|
|
||||||
|
```js
|
||||||
|
this.keyboard.clearInput();
|
||||||
|
```
|
||||||
|
|
||||||
|
### getInput
|
||||||
|
|
||||||
|
> Get the keyboard's input (You can also get it from the _onChange_ prop).
|
||||||
|
|
||||||
|
```js
|
||||||
|
let input = this.keyboard.getInput();
|
||||||
|
```
|
||||||
|
|
||||||
|
### setInput
|
||||||
|
|
||||||
|
> Set the keyboard's input. Useful if you want the keybord to initialize with a default value, for example.
|
||||||
|
|
||||||
|
```js
|
||||||
|
this.keyboard.setInput("Hello World!");
|
||||||
|
```
|
||||||
|
|
||||||
|
It returns a promise, so if you want to run something after it's applied, call it as so:
|
||||||
|
|
||||||
|
```js
|
||||||
|
let inputSetPromise = this.keyboard.setInput("Hello World!");
|
||||||
|
|
||||||
|
inputSetPromise.then((result) => {
|
||||||
|
console.log("Input set");
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
<img src="src/demo/images/demo.gif" align="center" width="600">
|
<img src="src/demo/images/demo.gif" align="center" width="600">
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "simple-keyboard",
|
"name": "simple-keyboard",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"description": "React.js Virtual Keyboard",
|
"description": "React.js Virtual Keyboard",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user