To use keys, start by adding a dependency to it using useKeys().
Then, you can add a keysInput to the UI:
library(shiny)
library(keys)
hotkeys <- c(
"1",
"command+shift+k",
"up up down down left right left right b a enter"
)
ui <- fluidPage(
useKeys(),
keysInput("keys", hotkeys)
)
server <- function(input, output, session) {
observeEvent(input$keys, {
print(input$keys)
})
}
shinyApp(ui, server)
You can add binding after application launch using addKeys.
keys
The goal of
keysis to add hotkeys to shiny applications usingMousetrap. Withkeys, you can:Installation
Install the released version of
keysfrom CRAN:Or install the development version from GitHub with:
You can also install
keyswithconda-forge. More information here: https://github.com/conda-forge/r-keys-feedstockUsage
To use
keys, start by adding a dependency to it usinguseKeys().Then, you can add a
keysInputto the UI:You can add binding after application launch using
addKeys.Bindings can be removed after application launch using
removeKey.For more information about what types of hotkeys you can use, please take a look at the mousetrap github repository.
Acknowledgements
All credit goes to Craig Campbell who is the author of
Mousetrap.