-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
71 lines (56 loc) · 1.85 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
---
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 = "man/figures/README-",
out.width = "100%"
)
```
# shinykeybindings
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
Set keybindings that allow you to navigate your Shiny App using keyboard
shortcuts.<br/>
This package lets you <br/>
:point_left: perform clicking actions <br/>
:eyeglasses: focus widgets <br/>
:clock130: trigger reactivity <br/>
:heavy_check_mark: set values of radio buttons
## Installation
You can install the latest released version of shinykeybindings from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("OekoFor/shinykeybindings@*release")
```
## Example
This minimal example adds the keyboard shortcut **ctrl + Enter** to the example app of `shiny::actionButton()`
```{r example}
library(shinykeybindings)
## Only run examples in interactive R sessions
if (interactive()) {
ui <- fluidPage(
sliderInput("obs", "Number of observations", 0, 1000, 500),
actionButton("goButton", "Go!", class = "btn-success"),
plotOutput("distPlot"),
# keybinding
kb_click("goButton", key = "Enter", modifier = "ctrl")
)
server <- function(input, output) {
output$distPlot <- renderPlot({
# Take a dependency on input$goButton. This will run once initially,
# because the value changes from NULL to 0.
input$goButton
# Use isolate() to avoid dependency on input$obs
dist <- isolate(rnorm(input$obs))
hist(dist)
})
}
shinyApp(ui, server)
}
```
For a complete example Shiny App run `kb_examples()`