Create a key input that can be used to record keys pressed by the user.
keysRecordInput(inputId)
recordKeys(inputId, session = shiny::getDefaultReactiveDomain())
The input slot that will be used to access the value.
The session
object passed to function given to
shinyServer
. Default is getDefaultReactiveDomain()
.
if (interactive()) {
library(shiny)
ui <- fluidPage(
useKeys(),
keysRecordInput("recorder"),
keysInput("keys", "command+shift+k"),
actionButton("record", "Record keys")
)
server <- function(input, output, session) {
observeEvent(input$record, {
print("recording keys...")
recordKeys("recorder")
})
observeEvent(input$recorder, {
print("adding keys...")
addKeys("keys", input$recorder)
})
observeEvent(input$keys, {
print(input$keys)
})
}
shinyApp(ui, server)
}