Set keybindings that allow you to navigate your Shiny App using keyboard
shortcuts.
This package lets you
👈 perform clicking actions
👓 focus widgets
🕜 trigger reactivity
✔️ set values of radio buttons
You can install the latest released version of shinykeybindings from GitHub with:
# install.packages("devtools")
devtools::install_github("OekoFor/shinykeybindings@*release")
This minimal example adds the keyboard shortcut ctrl + Enter to the
example app of shiny::actionButton()
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()