r4fun / keys

:keyboard: Keyboard Shortcuts for 'shiny'
https://r4fun.github.io/keys/
Other
45 stars 6 forks source link

Record #7

Closed tylerlittlefield closed 4 years ago

tylerlittlefield commented 4 years ago

@ColinFay In case you wanted to review before I merge.

This PR adds:

Expected usage is to initialize a keysInput and keysRecordInput so that you can record keys and add them with addKeys:

library(shiny)
library(keys)

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)