Skip to content

Commit d7b6b57

Browse files
author
Marty Wallace
committed
Bump to 2.0.0.
1 parent ba83853 commit d7b6b57

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

README.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,44 @@ This component is available through [Bower](https://bower.io/search/?q=vue-keybo
1313
Simply add the `keyboard` component to your Vue application:
1414

1515
```
16-
<keyboard chars="abc123|xyz456|{space:space}"></keyboard>
16+
<keyboard layouts="abc123|xyz456|{space:space}"></keyboard>
1717
```
1818

19-
The `chars` property accepts a pipe `|` delimited string of characters to use as the keyboard buttons. You can include special function characters with the `{text:action}` syntax, where `text` is the text that will be rendered in the button and `action` is the action within the keyboard component to be called when that button is pressed. The inbuilt actions are:
19+
Each layout accepts a pipe `|` delimited string of characters to use as the keyboard buttons. You can include special function characters with the `{text:action}` syntax, where `text` is the text that will be rendered in the button and `action` is the action within the keyboard component to be called when that button is pressed. The inbuilt actions are:
2020

2121
* `backspace` - Remove one character from the end of the current value.
2222
* `space` - Insert one whitespace character.
2323
* `clear` - Clear the entire input value.
24+
* `goto:n` - Go to a new keyboard layout, replacing `n` with the index of the layout to load.
2425

2526
If the `action` does not match any of these inbuilt actions, an event will be dispatched by the keyboard component instead, using the action name as the event name. The keyboard component will be provided to the listener as the first argument.
2627

2728
> Note: You can simply use `{action}` which will create a button with no text content. This is useful for things like `space` which you may just want to render as a wide empty button.
2829
2930
## Props:
3031

31-
The possible component properties are:
32+
<table>
33+
<thead>
34+
<tr>
35+
<th>Prop</th>
36+
<th>Type</th>
37+
<th>Description</th>
38+
</tr>
39+
</thead>
40+
<tbody>
41+
<tr>
42+
<td><code>layouts</code></td>
43+
<td><code>string|string[]</code></td>
44+
<td>One or more keyboard layouts, explained above.</td>
45+
</tr>
46+
<tr>
47+
<td><code>maxlength</code></td>
48+
<td><code>number</code></td>
49+
<td>The maximum input length.</td>
50+
</tr>
51+
</tbody>
52+
</table>
3253

33-
* `chars` - The character list (explained above).
34-
* `maxlength` - The maximum length of `value`.
35-
36-
> Note: Because `maxlength` is a `Number` you must provide it with the Vue dynamic syntax e.g. `<keyboard :maxlength="10">` not `<keyboard maxlength="10">` (the latter will be interpreted as a `String`).
37-
38-
## Interacting:
39-
40-
In regards to styling and interacting with the component, there are several routes:
41-
42-
* Buttons rendered with the `{text:action}` syntax will include a class name `action-x` where `x` is the name of the action e.g. `action-clear`.
43-
* General buttons will include a class name `char-x` where `x` is the text content e.g. `char-a`, `char-b`.
44-
* You can use `v-model="input"` to sync the keyboard value with a value in the parent Vue instance (named `input` in this case).
4554

4655
## Example:
4756

@@ -54,10 +63,6 @@ var app = new Vue({
5463
el: 'main',
5564
data: {
5665
input: '',
57-
layouts: [
58-
'1234567890{delete:backspace}|qwertyuiop|asdfghjkl|{shift:goto:1}zxcvbnm|{space:space}{custom:custom}',
59-
'!@#$%^&*(){delete:backspace}|QWERTYUIOP|ASDFGHJKL|{shift:goto:0}ZXCVBNM|{space:space}{custom:custom}'
60-
]
6166
},
6267
methods: {
6368
changed: function(value) {
@@ -74,7 +79,16 @@ var app = new Vue({
7479
Markup:
7580

7681
```
77-
<keyboard v-model="input" @input="change" @custom="custom" chars="qwertyuiop{backspace:backspace}|asdfghjkl|zxcvbnm|{space:space}{custom:custom}" :maxlength="16"></keyboard>
82+
<keyboard
83+
v-model="input"
84+
@custom="custom"
85+
@input="changed"
86+
:layouts="[
87+
'1234567890{delete:backspace}|qwertyuiop|asdfghjkl|{shift:goto:1}zxcvbnm|{space:space}{custom:custom}',
88+
'!@#$%^&*(){delete:backspace}|QWERTYUIOP|ASDFGHJKL|{shift:goto:0}ZXCVBNM|{space:space}{custom:custom}'
89+
]"
90+
:maxlength="16"
91+
></keyboard>
7892
```
7993

8094
This keeps the `input` value in the main application in sync with the value of the keyboard, limits that value to 16 characters and triggers the 'custom' function in the main application when the "custom" button in the keyboard is clicked.

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-keyboard",
3-
"version": "1.4.1",
3+
"version": "2.0.0",
44
"homepage": "https://github.com/MartyWallace/vue-keyboard",
55
"main": "dist/vue-keyboard.js",
66
"license": "MIT",

0 commit comments

Comments
 (0)