mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-03-16 08:21:07 +08:00
Updating documentation
This commit is contained in:
parent
d1e6630247
commit
dbed641621
40
README.md
40
README.md
@ -181,6 +181,30 @@ newLineOnEnter: false
|
|||||||
inputName: "default"
|
inputName: "default"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### onKeyPress
|
||||||
|
|
||||||
|
> Executes the callback function on key press. Returns button layout name (i.e.: "{shift}").
|
||||||
|
|
||||||
|
```js
|
||||||
|
onKeyPress: (button) => console.log(button)
|
||||||
|
```
|
||||||
|
|
||||||
|
### onChange
|
||||||
|
|
||||||
|
> Executes the callback function on input change. Returns the current input's string.
|
||||||
|
|
||||||
|
```js
|
||||||
|
onChange: (input) => console.log(input)
|
||||||
|
```
|
||||||
|
|
||||||
|
### onChangeAll
|
||||||
|
|
||||||
|
> Executes the callback function on input change. Returns the input object with all defined inputs. This is useful if you're handling several inputs with simple-keyboard, as specified in the "*[Using several inputs](#using-several-inputs)*" guide.
|
||||||
|
|
||||||
|
```js
|
||||||
|
onChangeAll: (inputs) => console.log(inputs)
|
||||||
|
```
|
||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
simple-keyboard has a few methods you can use to further control it's behavior.
|
simple-keyboard has a few methods you can use to further control it's behavior.
|
||||||
@ -201,7 +225,12 @@ keyboard.methodName(params);
|
|||||||
> Clear the keyboard's input.
|
> Clear the keyboard's input.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
// For default input (i.e. if you have only one)
|
||||||
keyboard.clearInput();
|
keyboard.clearInput();
|
||||||
|
|
||||||
|
// For specific input
|
||||||
|
// Must have been previously set using the "inputName" prop.
|
||||||
|
keyboard.clearInput("inputName");
|
||||||
```
|
```
|
||||||
|
|
||||||
### getInput
|
### getInput
|
||||||
@ -209,7 +238,12 @@ keyboard.clearInput();
|
|||||||
> Get the keyboard's input (You can also get it from the _onChange_ prop).
|
> Get the keyboard's input (You can also get it from the _onChange_ prop).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
// For default input (i.e. if you have only one)
|
||||||
let input = keyboard.getInput();
|
let input = keyboard.getInput();
|
||||||
|
|
||||||
|
// For specific input
|
||||||
|
// Must have been previously set using the "inputName" prop.
|
||||||
|
let input = keyboard.getInput("inputName");
|
||||||
```
|
```
|
||||||
|
|
||||||
### setInput
|
### setInput
|
||||||
@ -217,7 +251,12 @@ let input = keyboard.getInput();
|
|||||||
> Set the keyboard's input. Useful if you want the keybord to initialize with a default value, for example.
|
> Set the keyboard's input. Useful if you want the keybord to initialize with a default value, for example.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
// For default input (i.e. if you have only one)
|
||||||
keyboard.setInput("Hello World!");
|
keyboard.setInput("Hello World!");
|
||||||
|
|
||||||
|
// For specific input
|
||||||
|
// Must have been previously set using the "inputName" prop.
|
||||||
|
keyboard.setInput("Hello World!", "inputName");
|
||||||
```
|
```
|
||||||
|
|
||||||
### setOptions
|
### setOptions
|
||||||
@ -260,6 +299,7 @@ For example:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
> [See full example](https://github.com/hodgef/simple-keyboard/blob/master/src/demo/MultipleInputsDemo.js).
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user