mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-31 18:49:47 +08:00
Improved readme examples
This commit is contained in:
parent
d477c35cce
commit
cbd1506f53
51
README.md
51
README.md
@ -14,9 +14,17 @@
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
### npm
|
||||||
|
|
||||||
`npm install simple-keyboard --save`
|
`npm install simple-keyboard --save`
|
||||||
|
|
||||||
## Usage
|
### zip file (self-hosted)
|
||||||
|
|
||||||
|
[Click here to download the latest release (zip format).](https://github.com/hodgef/simple-keyboard/zipball/master)
|
||||||
|
|
||||||
|
> Want to use a CDN instead of self-host? Scroll down to the "Usage from CDN" instructions below.
|
||||||
|
|
||||||
|
## Usage with npm
|
||||||
|
|
||||||
### js
|
### js
|
||||||
|
|
||||||
@ -24,10 +32,28 @@
|
|||||||
import Keyboard from 'simple-keyboard';
|
import Keyboard from 'simple-keyboard';
|
||||||
import 'simple-keyboard/build/css/index.css';
|
import 'simple-keyboard/build/css/index.css';
|
||||||
|
|
||||||
var keyboard = new Keyboard({
|
class App {
|
||||||
|
constructor(){
|
||||||
|
document.addEventListener('DOMContentLoaded', this.onDOMLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
|
onDOMLoaded = () => {
|
||||||
|
this.keyboard = new Keyboard({
|
||||||
onChange: input => this.onChange(input),
|
onChange: input => this.onChange(input),
|
||||||
onKeyPress: button => this.onKeyPress(button)
|
onKeyPress: button => this.onKeyPress(button)
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onChange = input => {
|
||||||
|
console.log("Input changed", input);
|
||||||
|
}
|
||||||
|
|
||||||
|
onKeyPress = button => {
|
||||||
|
console.log("Button pressed", button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
||||||
````
|
````
|
||||||
|
|
||||||
### html
|
### html
|
||||||
@ -38,6 +64,23 @@ var keyboard = new Keyboard({
|
|||||||
|
|
||||||
> Need a more extensive example? [Click here](https://github.com/hodgef/simple-keyboard/blob/master/src/demo/App.js).
|
> Need a more extensive example? [Click here](https://github.com/hodgef/simple-keyboard/blob/master/src/demo/App.js).
|
||||||
|
|
||||||
|
## Usage from CDN
|
||||||
|
|
||||||
|
### html
|
||||||
|
|
||||||
|
````html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="https://cdn.rawgit.com/hodgef/simple-keyboard/d477c35c/build/css/index.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="simple-keyboard"></div>
|
||||||
|
<script src="https://cdn.rawgit.com/hodgef/simple-keyboard/d477c35c/build/index.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
````
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
You can customize the Keyboard by passing options to it.
|
You can customize the Keyboard by passing options to it.
|
||||||
@ -118,7 +161,7 @@ newLineOnEnter: false
|
|||||||
|
|
||||||
## Methods
|
## Methods
|
||||||
|
|
||||||
simple-keybord 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.
|
||||||
To access these functions, you need the instance the simple-keyboard component, like so:
|
To access these functions, you need the instance the simple-keyboard component, like so:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
Loading…
Reference in New Issue
Block a user