-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
113 lines (64 loc) · 2.54 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "inst/images/README-",
out.width = "100%"
)
```
# shinykeyboard
<!-- badges: start -->
<!-- badges: end -->
{shinykeyboard} is an R package to create an on-screen keyboard input widget in R Shiny. The package converts beautiful keyboards from Sharla Gelfand's {[ggkeyboard](https://github.com/sharlagelfand/ggkeyboard)} package and turns them into real, clickable on-screen keyboards that return a value of the keystroke.
## Installation
You can install the released version of {shinykeyboard} from GitHub with:
``` r
remotes::install_github("willdebras/shinykeyboard")
```
## Usage
The package contains a single UI input function `keyboardInput()` that takes two parameters:
* `inputId` - the ID of the input
* `color_palette` - one of three color palettes from the {ggkeyboard} package
```{r ex, eval = FALSE}
keyboardInput(inputId = "keebs", color_palette = "sharla3")
```
An on-screen keyboard will appear in your shiny app.
![example on screen keyboard](inst/images/sharla3.png)
To return the value for a single key, simply click the key or input the keystroke on your computer keyboard.
![example of a keystroke](inst/images/key_1.png)
To return multiple keystrokes together, either input keystrokes on a keyboard at the same time or toggle the multi-stroke switch at the top of the keyboard.
![example of a keystroke](inst/images/key_2.png)
## Customization
The package contains three palettes to use by passing to the `color_palette` parameter.
`keyboardInput(inputId = "keebs", color_palette = "sharla1")`
```{r, out.width = "60%", echo = FALSE}
knitr::include_graphics("inst/images/sharla1.png")
```
`keyboardInput(inputId = "keebs", color_palette = "sharla2")`
```{r, out.width = "60%", echo = FALSE}
knitr::include_graphics("inst/images/sharla2.png")
```
`keyboardInput(inputId = "keebs", color_palette = "sharla3")`
```{r, out.width = "60%", echo = FALSE}
knitr::include_graphics("inst/images/sharla3.png")
```
## Example
An example application using the shinykeyboard input:
```{r, eval = FALSE}
library(shiny)
library(shinykeyboard)
ui <- function() {
fluidPage(
keyboardInput("keebs", color_palette = "sharla1"),
verbatimTextOutput("debug")
)
}
server <- function(input, output) {
output$debug <- renderPrint(input$keebs)
}
shinyApp(ui = ui, server = server)
```